mardi 4 août 2015

PHP - How to merge foreach arrays into one loop

Here is my code:

$url = "http://ift.tt/1IDweUE";

libxml_use_internal_errors(true); 
$doc = new DOMDocument();
$doc->loadHTMLFile($url);

$xpath = new DOMXpath($doc);

$n = $xpath->query('//td[@data-column-name="Model"]');
$r = $xpath->query('//td[@data-column-name="RAM"]');

foreach ($n as $entry) {
    $Name = $entry->nodeValue;
    $RAM  = $r->nodeValue;
    echo " $Name - RAM: $RAM<br>";
}

I successfully echo $Name but i can not get the value for $RAM because i do not have it in my array. My question is how i can add $r into this foreach loop and make it work ?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire