Пример #1
0
 /**
  * Finds position of first occurrence of a UTF-8 string. This is a
  * UTF8-aware version of [strpos](http://php.net/strpos).
  *
  *     $position = UTF8::strpos($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
  * @uses    Kohana::$charset
  */
 public static function wpstrpos($str, $search, $offset = 0)
 {
     $offset = (int) $offset;
     if (UTF8::is_ascii($str) and UTF8::is_ascii($search)) {
         return strpos($str, $search, $offset);
     }
     if ($offset == 0) {
         $array = explode($search, $str, 2);
         return isset($array[1]) ? UTF8::wpstrlen($array[0]) : FALSE;
     }
     $str = UTF8::wpsubstr($str, $offset);
     $pos = UTF8::wpstrpos($str, $search);
     return $pos === FALSE ? FALSE : $pos + $offset;
 }