I have used preg match to find in a page all img tags:
<(img)[^>]*?>
Can someone please tell me how i would check if it has a full url and if it does not replace it with a full url from a variable called $link2. I would also like to be able to process urls which have change directory such as: ../images/example.gif --> to http://example.com/images/example.gif using the http://example.com previously stored in $link2.
I have tried, without any luck:
if ($urlres = true) {
for($i = 0, $size = sizeof($matches[0]); $i < $size; ++$i)
{
$imgurl = preg_match_all('#http:\/\/#si', $matches[0][$i], $matches);
if ($imgurl = true) {break;} else
preg_replace('#src="#si', '#src="$link2#', $matches[0][$i]);
}
}
Thanks