Soldato
I've written the following to highlight search terms:
$t is the search term, now this can be a comma seperated list (if q = and it is csv), hence the explode. However, only the first 'exploded' item is highlighted.
I'm too tired to spot my mistake, but I think it's by ***.
Any ideas?
Code:
function highlight($text, $t, $q){
if ($q == "and") {
$array = explode(", ", $t);
foreach ($array as &$value){
$text = str_replace(strtolower($value), "<span class=\"highlight\">" . strtolower($value) . "</span>", $text);
$text = str_replace(strtoupper($value), "<span class=\"highlight\">" . strtoupper($value) . "</span>", $text);
}
*** return $text;
}else{
$text = str_replace(strtolower($t), "<span class=\"highlight\">" . strtolower($t) . "</span>", $text);
$text = str_replace(strtoupper($t), "<span class=\"highlight\">" . strtoupper($t) . "</span>", $text);
return $text;
}
}
$t is the search term, now this can be a comma seperated list (if q = and it is csv), hence the explode. However, only the first 'exploded' item is highlighted.
I'm too tired to spot my mistake, but I think it's by ***.
Any ideas?