how are you doing it for only the FIRST???
Anyhoo, a simple string replace should do it... I'd do this:
$result = str_replace($search,span
class=\highlight\{$search}/span,$result);
Justin
on 04/11/02 6:27 PM, David Russell ([EMAIL PROTECTED]) wrote:
Hi there,
My brain has just gone very
-7250
Fax: +2711 444-7256
e-mail: [EMAIL PROTECTED]
web: www.BarloworldOptimus.com
-Original Message-
From: Justin French [mailto:justin;indent.com.au]
Sent: 04 November 2002 12:49 PM
To: David Russell
Subject: Re: [PHP] Battling with highlighting search criteria
Yeap, you need a regexp
[mailto:justin;indent.com.au]
Sent: 04 November 2002 12:49 PM
To: David Russell
Subject: Re: [PHP] Battling with highlighting search criteria
Yeap, you need a regexp...
$result = eregi_replace($search,span
class=\foo\$search/span,$result);
This will be a little slower that str_replace
-7250
Fax: +2711 444-7256
e-mail: [EMAIL PROTECTED]
web: www.BarloworldOptimus.com
-Original Message-
From: Justin French [mailto:justin;indent.com.au]
Sent: 04 November 2002 12:49 PM
To: David Russell
Subject: Re: [PHP] Battling with highlighting search criteria
Yeap, you need
$result = eregi_replace(($search),span
class=hightlight\\0/span,$result) ;
I use it, and I work fine for me.
- Original Message -
From: David Russell [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, November 04, 2002 7:27 PM
Subject: [PHP] Battling with highlighting search criteria
On Mon, 4 Nov 2002 11:59:20 +0200, you wrote:
Ok, this works.
Just one more thing,
How can I get the return in the same case as it was originally?
Use backreferences to capture what matched and use that in the replace
string. Example:
?
$search = is;
$str = This is a test, isn't it?;
$str =
6 matches
Mail list logo