note 31712 added to function.ereg-replace
| From: | bdwebtech at yahoo dot ca | Date: | Thu, 01 May 2003 03:51:11 +0000 |
| Subject: | note 31712 added to function.ereg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47316@lists.php.net to get a copy of this message | ||
It seems that I can not use a dollar sign ($) when back referencing some text while using the
ereg_replace() function.
bob at valinor dot ws solved this problem using
preg_replace().
>>>
Copy of Original Message form preg_replace() user notes:
bob at valinor dot ws
06-Mar-2002 12:02
I was having trouble getting the preg_replace() function to search a string for {{key}} and replace
it with the value from $row["key"] which was a line of results from a database uery. Here
is what I ended up with that does work, and figured someone else might find it useful. I use this so
that I can have a single function that I pass a query and a template to and let it fill in all of
the data.
$new = preg_replace('/{{([A-Za-z]*)}}/e', "\$row['\\1']" ,$format);
--
http://www.php.net/manual/en/function.ereg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+31712
http://master.php.net/manage/user-notes.php?action=delete+31712
http://master.php.net/manage/user-notes.php?action=reject+31712