Merging website info into an array
I think that one of the collections you iterate already has all the data you need. Try this:

$linkQuery = $xpath-&gt;query("//div[@class='news-archive']//a");
foreach ($linkQuery as $link) {
    $data[] = array('link' =&gt; $link-&gt;getAttribute('href'), 'title' =&gt; $link-&gt;nodeValue);
}


Btw. array_map() is another way for traversing two (or more) arrays simultaneously:

$group_elements = function($link, $title) {
    return array('link' =&gt; $link-&gt;value, 'title' =&gt; $title-&gt;nodeValue);
};
$data = array_map($group_elements, $linkQuery, $titleQuery);