note 31712 deleted from function.ereg-replace by tularis
| From: | tularis@php.net | Date: | Sun, 29 Aug 2004 12:13:51 +0000 |
| Subject: | note 31712 deleted from function.ereg-replace by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75557@lists.php.net to get a copy of this message | ||
Note Submitter: bdwebtech at yahoo dot ca
----
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);