Finds position of last occurrence of a char in a UTF-8 string. This is a UTF8-aware version of strrpos.
$position = UTF8::strrpos($str, $search);
integer Core_UTF8::strrpos( string $str , string $search [, integer $offset = integer 0 ] )
参数列表
参数 类型 描述 默认值 $str
string
Haystack $search
string
Needle $offset
integer
Offset from which character in haystack to start searching integer 0
integer
position of needleboolean
FALSE if the needle is not foundpublic static function strrpos($str, $search, $offset = 0)
{
$offset = (int)$offset;
if (IS_MBSTRING) return mb_strrpos($str, $search, $offset, Core::$charset);
if ( UTF8::is_ascii($str) and UTF8::is_ascii($search) ) return strrpos($str, $search, $offset);
if ( $offset == 0 )
{
$array = explode($search, $str, - 1);
return isset($array[0]) ? UTF8::strlen(implode($search, $array)) : FALSE;
}
$str = UTF8::substr($str, $offset);
$pos = UTF8::strrpos($str, $search);
return ($pos === FALSE) ? FALSE : $pos + $offset;
}