1 <?php
2 /**
3 * @package utf8
4 */
5
6 //---------------------------------------------------------------
7 /**
8 * UTF-8 aware alternative to stristr
9 * Find first occurrence of a string using case insensitive comparison
10 * Note: requires utf8_strtolower
11 * @param string
12 * @param string
13 * @return int
14 * @see http://www.php.net/strcasecmp
15 * @see utf8_strtolower
16 * @package utf8
17 */
18 function utf8_stristr($str, $search) {
19
20 if ( strlen($search) == 0 ) {
21 return $str;
22 }
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
30 if ( count($matches) == 2 ) {
31 return substr($str, strlen($matches[1]));
32 }
33
34 return FALSE;
35 }
36