예제 #1
0
파일: UTF8.php 프로젝트: gnribeiro/turim
 /**
  * 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 <*****@*****.**>
  * @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;
 }