$text = mb_ereg_replace("$search", "<span class='search_item'>{$search}</span>", $text, "i");
function mb_ucfirst($str, $encoding='UTF-8') {
$str = mb_ereg_replace('^[\ ]+', '', $str);
$str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding).
mb_substr($str, 1, mb_strlen($str), $encoding);
return $str;
}
private function light($search, $text) {
mb_internal_encoding("UTF-8");
mb_regex_encoding("UTF-8");
$expArr = explode($search, $text);
$searchArray = array();
$searchArray[] = mb_strtoupper($search);
$searchArray[] = mb_strtolower($search);
$searchArray[] = self::mb_ucfirst($search);
$searchArray[] = self::mb_ucfirst($search, true);
foreach($searchArray as $search) {
$text = mb_eregi_replace($search, "<span class='search_item'>{$search}</span>", $text);
}
return $text;
}
private function mb_ucfirst($str, $recursion = false, $encoding = 'UTF-8') {
if($recursion) {
$string = explode(' ', $str);
foreach($string as $key => $word) {
$string[$key] = self::mb_ucfirst($word);
}
return implode(' ', $string);
}
$str = mb_ereg_replace('^[\ ]+', '', $str);
$str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding).
mb_substr($str, 1, mb_strlen($str), $encoding);
return $str;
}