PageRenderTime 64ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/server/system/core/utf8/stristr.php

https://github.com/ozten/mobhat
PHP | 28 lines | 14 code | 5 blank | 9 comment | 4 complexity | 25afafb2566ddfc99faf296fe65def5f MD5 | raw file
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. /**
  3. * utf8::stristr
  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 _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, '/').'/s', $str_lower, $matches);
  20. if (isset($matches[1]))
  21. return substr($str, strlen($matches[1]));
  22. return FALSE;
  23. }