PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/system/core/utf8/strrpos.php

https://github.com/lmorchard/friendfeedarchiver
PHP | 30 lines | 17 code | 4 blank | 9 comment | 4 complexity | 3a31e910500a686fe3e7f55da7c2fde6 MD5 | raw file
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3. * utf8::strrpos
  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 _strrpos($str, $search, $offset = 0)
  12. {
  13. $offset = (int) $offset;
  14. if (SERVER_UTF8)
  15. return mb_strrpos($str, $search, $offset);
  16. if (utf8::is_ascii($str) AND utf8::is_ascii($search))
  17. return strrpos($str, $search, $offset);
  18. if ($offset == 0)
  19. {
  20. $array = explode($search, $str, -1);
  21. return (isset($array[0])) ? utf8::strlen(implode($search, $array)) : FALSE;
  22. }
  23. $str = utf8::substr($str, $offset);
  24. $pos = utf8::strrpos($str, $search);
  25. return ($pos === FALSE) ? FALSE : $pos + $offset;
  26. }