strrpos.php 664 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * UTF8::strrpos
  4. *
  5. * @package Kohana
  6. * @author Kohana Team
  7. * @copyright (c) 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 (UTF8::is_ascii($str) AND UTF8::is_ascii($search))
  15. return strrpos($str, $search, $offset);
  16. if ($offset == 0)
  17. {
  18. $array = explode($search, $str, -1);
  19. return isset($array[0]) ? UTF8::strlen(implode($search, $array)) : FALSE;
  20. }
  21. $str = UTF8::substr($str, $offset);
  22. $pos = UTF8::strrpos($str, $search);
  23. return ($pos === FALSE) ? FALSE : ($pos + $offset);
  24. }