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.