On Mon, 8 Sep 2003 00:11:09 +0200, Jonas_weber @ Gmx . Ch <[EMAIL PROTECTED]> wrote:

Am Sonntag, 07.09.03 um 21:17 Uhr schrieb John W. Holmes:

output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found anymore.)
but how to work around it??

Highlight the longest words first?

I don't think that would change anything. A search for "te est" then highlights "test" into "t<b>est</b>" and "te" can't be found anymore.

Why not just allow for bold tags in the search term? What I mean is, I think you can get the results you want by allowing any number of open or close bold tags between each letter of the search term.


<?php
function highlight($src_terms, $src_terms_int, $result) {
$i = 0;
while ($i < $src_terms_int) {
$termWithOptionalBold = preg_replace('/(.)/', '(<\/?b>) *\1',$src_terms[$i]);
$result = preg_replace('/(<\/?b>)*('.$termWithOptionalBold.')(<\/?b>) */si', '<b>\2</b>', $result);
$i++;
}
return $result;
}
?>
--
Lee O'Mara


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to