本文整理汇总了PHP中UTF8::wpstrrpos方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::wpstrrpos方法的具体用法?PHP UTF8::wpstrrpos怎么用?PHP UTF8::wpstrrpos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::wpstrrpos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpstrrpos
/**
* Finds position of last occurrence of a char in a UTF-8 string. This is
* a UTF8-aware version of [strrpos](http://php.net/strrpos).
*
* $position = UTF8::strrpos($str, $search);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str haystack
* @param string $search needle
* @param integer $offset offset from which character in haystack to start searching
* @return integer position of needle
* @return boolean FALSE if the needle is not found
* @uses UTF8::$server_utf8
*/
public static function wpstrrpos($str, $search, $offset = 0)
{
$offset = (int) $offset;
if (UTF8::is_ascii($str) and UTF8::is_ascii($search)) {
return wpstrrpos($str, $search, $offset);
}
if ($offset == 0) {
$array = explode($search, $str, -1);
return isset($array[0]) ? UTF8::wpstrlen(implode($search, $array)) : FALSE;
}
$str = UTF8::wpsubstr($str, $offset);
$pos = UTF8::wpstrrpos($str, $search);
return $pos === FALSE ? FALSE : $pos + $offset;
}