PageRenderTime 42ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/joomla/libraries/phputf8/stristr.php

https://github.com/reechalee/joomla1.6
PHP | 38 lines | 13 code | 5 blank | 20 comment | 4 complexity | a408e6c7ef9ed00bac152cf6cf20e53b MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause, JSON
  1. <?php
  2. /**
  3. * @version $Id: stristr.php 18618 2010-08-24 03:21:05Z ian $
  4. * @package utf8
  5. * @subpackage strings
  6. */
  7. //---------------------------------------------------------------
  8. /**
  9. * UTF-8 aware alternative to stristr
  10. * Find first occurrence of a string using case insensitive comparison
  11. * Note: requires utf8_strtolower
  12. * @param string
  13. * @param string
  14. * @return int
  15. * @see http://www.php.net/strcasecmp
  16. * @see utf8_strtolower
  17. * @package utf8
  18. * @subpackage strings
  19. */
  20. function utf8_stristr($str, $search) {
  21. if ( strlen($search) == 0 ) {
  22. return $str;
  23. }
  24. $lstr = utf8_strtolower($str);
  25. $lsearch = utf8_strtolower($search);
  26. //JOOMLA SPECIFIC FIX - BEGIN
  27. preg_match('/^(.*)'.preg_quote($lsearch, '/').'/Us',$lstr, $matches);
  28. //JOOMLA SPECIFIC FIX - END
  29. if ( count($matches) == 2 ) {
  30. return substr($str, strlen($matches[1]));
  31. }
  32. return FALSE;
  33. }