stristr.php 633 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * UTF8::stristr
  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 _stristr($str, $search)
  12. {
  13. if (UTF8::is_ascii($str) AND UTF8::is_ascii($search))
  14. return stristr($str, $search);
  15. if ($search == '')
  16. return $str;
  17. $str_lower = UTF8::strtolower($str);
  18. $search_lower = UTF8::strtolower($search);
  19. preg_match('/^(.*?)'.preg_quote($search_lower, '/').'/s', $str_lower, $matches);
  20. if (isset($matches[1]))
  21. return substr($str, strlen($matches[1]));
  22. return FALSE;
  23. }