note 11561 added to ereg_replace
| From: | tarwin at mail dot com | Date: | Sun, 25 Feb 2001 08:37:19 +0000 |
| Subject: | note 11561 added to ereg_replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11581@lists.php.net to get a copy of this message | ||
I've been trying to, after a search, place "<span
class=classname>$string</span>"
I can do that easily enough but the problem is it replaces that $string is also replaced inside
other markers.
eg : if $string = "image"; then it also makes <IMG SRC=images/name.gif> into <IMG
SRC=<span>image</span>s/name.gif>
I tried playing around with ereg_replace but could only come up with the following
$rep = "a|e|!";
$newstring = eregi_replace(">([^<>]*)($rep)([^<>]*)<",
">\\1<b>\\2</b>\\3<", "<>a asdf asdf a a<asdf asdf
asdf>h>el<l>o!!!<asdf asd f>");
print $newstring;
This puts bold anything in $rep but only seems to do it to the last instance. For example it will
only make bold the 3rd 'a' in the string as well as the 'e' and the third
'!'.
Can anyone help me?!
http://www.php.net/manual/en/function.ereg-replace.php