Re: Re: Battling with highlighting search criteria
| From: | Erwin | Date: | Mon, 04 Nov 2002 09:27:22 +0000 |
| Subject: | Re: Re: Battling with highlighting search criteria | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122645@lists.php.net to get a copy of this message | ||
David Russell wrote:
> Hey there
>
> I told you my brain was feeling fuzzy :)
>
> This works great. Only one problem... I would like it to be case
> insensitive... Any way?
>
> I assume that it would be a ereg/preg replace, but I have no clue with
> regexp at all.
Try the following one:
$result = "This is a test, isn't it?";
$search = "is";
$result = preg_replace( '/(' . $search . ')/i', "<span
class=\"highlight\">\$1</span>", $result );
Grtz Erwin