<?php
if(!function_exists('str_ireplace')) {
function str_ireplace($search, $replacement, $string){
$delimiters = array(1
,2
,3
,4
,5
,6
,7
,8
,14
,15
,16
,17
,18
,19
,20
,21
,22
,23
,24
,25
, 26,27,28,29,30,31,33,247,215,191,190,189,188,187,186,
185,184,183,182,180,177,176,175,174,173,172,171,169,
168,167,166,165,164,163,162,161,157,155,153,152,151,
150,149,148,147,146,145,144,143,141,139,137,136,135,
134,133,132,130,129,128,127,126,125,124,123,96,95,94,
63,62,61,60,59,58,47,46,45,44,38,37,36,35,34);
foreach ($delimiters as $d) {
if (strpos($string, chr
($d))===false){ $delimiter = chr($d);
break;
}
}
if (!empty($delimiter)) { }
else {
trigger_error('Homemade str_ireplace could not find a proper delimiter.', E_USER_ERROR
); }
}
}
function podswietl($tekst, $szukane){
$tekst=str_ireplace($szukane, '<SPAN STYLE="color: red; FONT-weight: bold;">'.$szukane.'</SPAN>', $tekst);
return $tekst;
}
?>
Jeżeli używasz PHP w wersji 5 to pierwszą funkcję możesz wywalić.
Podświetlanie wywołujesz poprzez:
<?php
echo podswietl
($miasto, $szukane); ?>