PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/system/utf8/stristr.php

https://bitbucket.org/herson091/kohana1
PHP | 28 lines | 14 code | 5 blank | 9 comment | 4 complexity | df34b74fd308f2b803ea9571c2231132 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3. * UTF8::stristr
  4. *
  5. * @package Kohana
  6. * @author Kohana Team
  7. * @copyright (c) 2007-2012 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. }