Php scrape working individually, but alongside other php no output

Experimenting with some php scrape testing to learn this thoroughly, and something unfortunate going on, where in individual PHP files, this code works just fine. However when I combine it into one php, I get an empty result, any clue why? This is basically a working data scrape that identifies content in the < p> and specifies what exact data to spit out, which is pretty cool.

Obviously there's an issue going on in the code that is preventing them from both spitting out an output when combined in the same php file. Thanks for reading this!

The output below was intended to give this: June 16, 2017 (21,384.28) June 8, 2017

Individually when they're working they give: June 16, 2017 (21,384.28) and June 8, 2017

<?php


$doc = new DOMDocument;

// We don't want to bother with white spaces
$doc->preserveWhiteSpace = false;

// Most HTML Developers are chimps and produce invalid markup...
$doc->strictErrorChecking = false;
$doc->recover = true;

 $doc->loadHTMLFile('http://www.fedprimerate.com/djia-chart-     history.htm');
 $xpath = new DOMXPath($doc);

 $query = "//p[contains(text(),'Record')]";


//function to check whether the element shoud be left
function deleteBlankInArray($var){
  return !ctype_space($var)&&!empty($var);
}

$entries = $xpath->query($query);
foreach ($entries as $entry) {
$result = trim($entry->textContent); 
$ret_ = explode(' ', $result);
//make sure every element in the array don't start or end with blank
foreach ($ret_ as $key=>$val){
$ret_[$key]=trim($val);
}
//delete the empty element and the element is blank "\n" "\r" "\t"
//I modify this line
$ret_ = array_values(array_filter($ret_,deleteBlankInArray));

 //echo the last element
echo $ret_[5];
echo '&nbsp';
echo $ret_[6];
echo '&nbsp';
echo $ret_[7];

}

?>


<?php


$doc = new DOMDocument;

// We don't want to bother with white spaces
$doc->preserveWhiteSpace = false;

// Most HTML Developers are chimps and produce invalid markup...
$doc->strictErrorChecking = false;
$doc->recover = true;

$doc->loadHTMLFile('http://www.fedprimerate.com/nasdaq-composite-history-
chart.htm');

 $xpath = new DOMXPath($doc);

$query = "//p[contains(text(),'Record')]";


//function to check whether the element shoud be left
function deleteBlankInArray($var){
  return !ctype_space($var)&&!empty($var);
}

$entries = $xpath->query($query);
foreach ($entries as $entry) {
$result = trim($entry->textContent); 
$ret_ = explode(' ', $result);
//make sure every element in the array don't start or end with blank
foreach ($ret_ as $key=>$val){
$ret_[$key]=trim($val);
}
//delete the empty element and the element is blank "\n" "\r" "\t"
//I modify this line
$ret_ = array_values(array_filter($ret_,deleteBlankInArray));

 //echo the last element
echo $ret_[5];
echo '&nbsp';
echo $ret_[6];
echo '&nbsp';
echo $ret_[7];

}

?>