How to make a working img src from a local img src - PHP
<p>I am using cURL to get the img srcs of all the img tags used in a website. But the website has many names specified without host names, like:</p>

<pre><code>&lt;img src="/images/look.jpg" /&gt;
&lt;img src="i4.ytimg.com/vi/OmliBRZUxnk/maxresdefault.jpg?feature=og" title="youtube pic" /&gt;
</code></pre>

<p>So how do I determine which of the src's will render the pic without any manipulation of them, and which one will need to be prepended with the site's host name (steekcoders.com).</p>

<p>Currently I'm trying this:</p>

<pre><code>$url = 'http://www.steekcoders.com'; $parse='http://'.parse_url($url, PHP_URL_HOST).'/'; $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

foreach($imgArray as $src)
{  
 $src=ltrim($src,"/"); if(empty($src)){ continue; }

if(!preg_match($reg_exUrl, $src))
{
 $clipouts[]=$src; $req="http://".$src; $extra=$parse.$src; 
 $clipouts[] = $extra; $clipouts[] = $req;
} 
else{ $clipouts[]=$src; {   

}
</code></pre>

<p>But it is not working out very well. How can I go about this?</p>
