urlencode not parsing \$2 in preg_replace - htmlentities is
Posted: Sun Aug 07, 2005 1:53 pm
I have
If I replace urlencode with htmlentities, \$2 gets converted to the SRC of the IMG tag.
Problem is that IMG SRC has a url in it like <IMG SRC="http://originaldomain.com?url=imagelocationdomain">
On using htmlenities I get
but on using urlencode I get
when urldecoded src is myimage.php?filename=http://originaldomain.com$2
when it should have been myimage.php?filename=http://originaldomain.com?url=imagelocationdomain
Problem : \$2 is not getting parsed when using urlencode - but its getting parsed when using htmlentities.
Any ideas why ?
Thanks.
Code: Select all
$val = preg_replace(
array("/(<img src=\")(.*?)(\")/is"),
array("\$1myimage.php?filename=".urlencode("\$2")."\$3"),
$val
);Problem is that IMG SRC has a url in it like <IMG SRC="http://originaldomain.com?url=imagelocationdomain">
On using htmlenities I get
Code: Select all
<img src="myimage.php?filename=http://originaldomain.com?url=imagelocationdomain">Code: Select all
<img src="myimage.php?filename=http%253A%252F%252Foriginaldomain.com%25242">when it should have been myimage.php?filename=http://originaldomain.com?url=imagelocationdomain
Problem : \$2 is not getting parsed when using urlencode - but its getting parsed when using htmlentities.
Any ideas why ?
Thanks.