strrpos.php 691 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * UTF8::strrpos
  4. *
  5. * @package KO7
  6. *
  7. * @copyright (c) 2007-2016 Kohana Team
  8. * @copyright (c) since 2016 Koseven Team
  9. * @copyright (c) 2005 Harry Fuecks
  10. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  11. */
  12. function _strrpos($str, $search, $offset = 0)
  13. {
  14. $offset = (int) $offset;
  15. if (UTF8::is_ascii($str) AND UTF8::is_ascii($search))
  16. return strrpos($str, $search, $offset);
  17. if ($offset == 0)
  18. {
  19. $array = explode($search, $str, -1);
  20. return isset($array[0]) ? UTF8::strlen(implode($search, $array)) : FALSE;
  21. }
  22. $str = UTF8::substr($str, $offset);
  23. $pos = UTF8::strrpos($str, $search);
  24. return ($pos === FALSE) ? FALSE : ($pos + $offset);
  25. }