Initial Kohana install
[speedfreak] / Server / system / core / utf8 / strpos.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * utf8::strpos
4  *
5  * @package    Core
6  * @author     Kohana Team
7  * @copyright  (c) 2007 Kohana Team
8  * @copyright  (c) 2005 Harry Fuecks
9  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
10  */
11 function _strpos($str, $search, $offset = 0)
12 {
13         $offset = (int) $offset;
14
15         if (SERVER_UTF8)
16                 return mb_strpos($str, $search, $offset);
17
18         if (utf8::is_ascii($str) AND utf8::is_ascii($search))
19                 return strpos($str, $search, $offset);
20
21         if ($offset == 0)
22         {
23                 $array = explode($search, $str, 2);
24                 return isset($array[1]) ? utf8::strlen($array[0]) : FALSE;
25         }
26
27         $str = utf8::substr($str, $offset);
28         $pos = utf8::strpos($str, $search);
29         return ($pos === FALSE) ? FALSE : $pos + $offset;
30 }