Julio,
Try this
$search = "Joe Doe";
$original = "Joe Cougar Doe";
$final = "<b>Joe</b> Cougar <b>Doe</b>";
$terms = explode(" ",$search);
for($i=0; $i<count($terms); $i++)
{
$original = eregi_replace($terms[$i], "<b>".$terms[$i]."</b>",
$original);
}
echo $original;
Should get you started.
Thank You
Brian Paulson
Sr. Web Developer
[EMAIL PROTECTED]
http://www.chieftain.com
-----Original Message-----
From: Julio Nobrega Trabalhando [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 8:36 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Replacing non exact strings
Hi List,
Imagine a form where user can search for clients using a 'name' field.
When submitted, there's a result page, linking results to another page
with
the client information.
I need to make the terms inputted at the form bold when they appear at
the
client information page. Problem is: When someone searchs for "Joe Doe",
and
the client's name is "Joe Doe", I can make it "<b>Joe Doe</b>".
But when the name is "Joe Cougar Doe", I can't bold it (parts Joe &&
Doe)
because there's this "Cougar" in the middle. The result I am looking for
is
"<b>Joe</b> Cougar <b>Doe</b>".
So:
$searched = "Joe Doe";
$original = "Joe Cougar Doe";
$final = "<b>Joe</b> Cougar <b>Doe</b>";
Any ideas about how can I achieve this result? I am currently using
eregi_replace($searched, "<b>$searched</b>", $original), so that's why
it
only accepts the whole string.
Thanks a lot,
Julio Nobrega.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php