Source code for file /phputf8/mbstring/core.php
Documentation is available at core.php
* @version $Id: core.php,v 1.4 2006/02/25 14:07:57 harryf Exp $
* Define UTF8_CORE as required
//--------------------------------------------------------------------
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strpos
* Find position of first occurrence of a string
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
if ( $offset ===
FALSE ) {
return mb_strpos($str, $search);
return mb_strpos($str, $search, $offset);
//--------------------------------------------------------------------
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strrpos
* Find position of last occurrence of a char in a string
* @param string needle (you should validate this with utf8_is_valid)
* @param integer (optional) offset (from left)
* @return mixed integer position or FALSE on failure
if ( $offset ===
FALSE ) {
# Emulate behaviour of strrpos rather than raising warning
return mb_strrpos($str, $search);
trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING);
$str =
mb_substr($str, $offset);
if ( FALSE !==
( $pos =
mb_strrpos($str, $search) ) ) {
//--------------------------------------------------------------------
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_substr
* Return part of a string given character offset (and optionally length)
* @param integer number of UTF-8 characters offset (from left)
* @param integer (optional) length in UTF-8 characters from offset
* @return mixed string or FALSE if failure
if ( $length ===
FALSE ) {
return mb_substr($str, $offset);
return mb_substr($str, $offset, $length);