How to fix when echo link url array in php?
<p>I have a code example:</p>

<pre><code>include 'simple_html_dom.php';
    // convert link url
    function foo($uri) {
        $url = parse_url($uri);
        $paths = explode('/', $url['path']);
        return sprintf("%s://%s/%s", $url['scheme'], 'localhost/test/get_image/images', end($paths));
    }
    $str = '&lt;img src="http://www.somedomain.com/somepic.jpg" /&gt;
    &lt;img src="http://www.microsoft.com/somepic.jpg" /&gt;';
    $html = new simple_html_dom();
    $html-&gt;load($str);
    // remove all image
    $arr_img = array();
    foreach($html-&gt;find('img') as $element) {
        $arr_img[] = $element-&gt;src;
    $str_rep = str_replace($element-&gt;src, foo($element-&gt;src), $str);
    }
    echo $str_rep;
</code></pre>

<blockquote>
  <p>OUTPUT:</p>
</blockquote>

<pre><code>&lt;img src="http://www.somedomain.com/somepic.jpg"&gt;
&lt;img src="http://localhost/test/get_image/images/somepic.jpg"&gt;
</code></pre>

<p>Error when can't get link "http://www.somedomain.com/somepic.jpg" not convert to "http://localhost/test/get_image/images/somepic.jpg"
How to fix it ?</p>
