You'll probably want to use preg_replace.

For instance:

$string = "/(PHP)/i";

$target = "Please highlight PhP for me.";

echo $target, '<br>';

$target = preg_replace($string, "<b>\\1</b>", $target);

echo $target, '<br>';


\\1 is whatever was found in the first parentheses(sp).


--
Plutarck
Should be working on something...
...but forgot what it was.


""Matt Williams"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi
>
> I'm implementing a simple keyword search.
> I want the results to be displayed with the keywords highlighted.
> I am currently using this to highlight the keywords
>
> str_replace($string,"<b>$string</b>",$field);
>
> If I search for php, it will find PHP, PhP etc... but using the above only
> php will will be highlighted, not PHP.
> I've tried eregi_replace but I could only get that to change the case and
> highlight that ie. PHP would become php.
>
> Can anyone point me in the direction of how to highlight the string
> regardless of case but keep the case for the match.
>
> TIA
>
> M@
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to