I am replacing a string in a text block that has a literal $ in it, and
preg_replace is seeing it as a backreference. Here is what I am using:
foreach($price_lists as $list)
$x=preg_replace('/--PRICE-LIST--/',$list,$x,1);
OK, so what this does it is takes each array element and replaces only
the first occurrance of "--PRICE-LIST--" with it. I would have used
str_replace, but I didn't think it should be necessary to create an
array with the same number of elements as $price_list just for a simple
thing like this.
I did, hoever try:
$x=str_replace('--PRICE-LIST--',$price_lists,$x);
Since the manual page didn't say anything about that case to no avail.
So right now I have the following:
foreach($price_lists as $list)
$x=preg_replace('/--PRICE-LIST--/',str_replace('$','\$',$list),$x,1);
Which compensates for this. However, that is just one case, I cane
forsee others showing up. Does anyone know of a way to make preg_replace
behave as I intend it to? Or does someone have a function for regex-safe
string encoding?
TIA!
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.