stristr.php 660 B

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