One result array
<p>I'm trying to add the results of a script to an array, but once I look into it there is only one item in it, probably me being silly with placement </p>

<pre><code>function crawl_page($url, $depth)
{
    static $seen = array();
    $Linklist = array();

    if (isset($seen[$url]) || $depth === 0) {
        return;
    }
    $seen[$url] = true;

    $dom = new DOMDocument('1.0');
    @$dom-&gt;loadHTMLFile($url);

    $anchors = $dom-&gt;getElementsByTagName('a');
    foreach ($anchors as $element) {
        $href = $element-&gt;getAttribute('href');
        if (0 !== strpos($href, 'http')) {
            $href = rtrim($url, '/') . '/' . ltrim($href, '/');
        }
        if(shouldScrape($href)==true)
        {
          crawl_page($href, $depth - 1);
        }

    }
    echo "URL:",$url;
    echo http_response($url);
    echo  "&lt;br/&gt;";
    $Linklist[] = $url;

    $XML = new DOMDocument('1.0');
    $XML-&gt;formatOutput = true;

    $root = $XML-&gt;createElement('Links');
    $root = $XML-&gt;appendChild($root);

    foreach ($Linklist as $value)
    {    
        $child = $XML-&gt;createElement('Linkdetails');
        $child = $root-&gt;appendChild($child);

        $text = $XML-&gt;createTextNode($value);
        $text = $child-&gt;appendChild($text);
    }        
    $XML-&gt;save("linkList.xml");      
}
</code></pre>
