Code: Select all
while ($r = mysql_fetch_array($result))
{
$title = $rї"title"];
$date = $rї"date"];
$vq = $rї"vq"];
$length = $rї"length"];
$format = $rї"format"];
if($syntax == 1) {
$ml = preg_replace("/\b($search*)\b/i","<span class="highlight">\\1</span>",$rї"ml"]);
} else {
$words = explode(' ', $search);
foreach( $words AS $word ) {
$ml = preg_replace("/\b($word*)\b/i","<span class="highlight">\\1</span>",$rї"ml"]); }
}
echo "<p class="bold" style="color: #186B08; font-size: 10pt;"> $title | $date | $vq | $length | $format </p>\n
<ol class="left">\n
$ml\n
</ol>\n\n";
}Code: Select all
else {
$words = explode(' ', $search);
foreach( $words AS $word ) {
$ml = preg_replace("/\b($word*)\b/i","<span class="highlight">\\1</span>",$rї"ml"]); }
}On a single word search, everything works fine. On a multiple word search however . . . Regardless of the number of words input, it will only highlight the last word.
It is supposed to take the regular search string, regardless of the amount of words input, explode it into an array, and for each word execute the highlighter then echo $ml.
I'm guessing this is something incredibly obvious involving the while loop and the foreach that's making it highlight the last word of the string only, but I honestly can't figure it out.
Thanks for any help in advance.
--Tony