Forum Moderators: coopster
I always thought the ereg_replace function could do it but i haven't figured out how to pass the selected keywords from a mysql database.
To sum it up.
How do you "heightlight" keywords taken from a database or a variable.
$var = "This is the ultimate keyword";
now if i wanted the word "ultimate" to be hightlighted, what would i do?
... Also i would like to know how to do this with multiple words.
If there is a simple function for this, or a previous thread about this, then pleas let me know.
Thanks for listening
$var_original = "This is the ultimate keyword";
$var_hlight = "<span style=\"background-color:#FFCC00; color:#0000FF; font-weight:bold;\">".$keyword."</span>";
$keyword = "ultimate";
$new_var = str_replace($keyword, $var_hlight, $var_original);