PageRenderTime 46ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/system/utf8/strpos.php

https://bitbucket.org/alameya/alameya_core
PHP | 27 lines | 15 code | 3 blank | 9 comment | 3 complexity | e11eb21e2c5f6827766ba6c79ca507dc MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3. * UTF8::strpos
  4. *
  5. * @package Kohana
  6. * @author Kohana Team
  7. * @copyright (c) 2007-2011 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. if (UTF8::is_ascii($str) AND UTF8::is_ascii($search))
  15. return strpos($str, $search, $offset);
  16. if ($offset == 0)
  17. {
  18. $array = explode($search, $str, 2);
  19. return isset($array[1]) ? UTF8::strlen($array[0]) : FALSE;
  20. }
  21. $str = UTF8::substr($str, $offset);
  22. $pos = UTF8::strpos($str, $search);
  23. return ($pos === FALSE) ? FALSE : ($pos + $offset);
  24. }