title: Can I get the result of domxpath nested classes into an array with keys => value?
body: <p>I'm getting some data from a webpage for clients and that works fine, it gets all data in seperate rows by exploding the \n into new lines which I then map to specific array data to fill form fields with. Like so for each needed value:</p>
  
  <pre><code>$lines = explode("\n", $html);
  $data['vraagprijs']         = preg_replace("/[^0-9]/", "", $lines[5]);
  </code></pre>
  
  <p>However, the data i need may be in Line 10 today, but might very well be line 11 tomorrow. So I'd like to get the values into named arrays. A sample of the HTML on the URL is as follows:</p>
  
  <pre><code>&lt;div class="item_list"&gt;             
  &lt;span class="item first status"&gt;
      &lt;span class="itemName"&gt;Status&lt;/span&gt;                        
      &lt;span class="itemValue"&gt;Sold&lt;/span&gt;
  &lt;/span&gt;
  &lt;span class="item price"&gt;
      &lt;span class="itemName"&gt;Vraagprijs&lt;/span&gt;
      &lt;span class="itemValue"&gt;389.000&lt;/span&gt;
  &lt;/span&gt;
  &lt;span class="item condition"&gt;
      &lt;span class="itemName"&gt;Aanvaarding&lt;/span&gt;
      &lt;span class="itemValue"&gt;In overleg&lt;/span&gt;
  &lt;/span&gt;
  ...
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my function model:</p>
  
  <pre><code>$tagName3   = 'div';
  $attrName3  = 'class';
  $attrValue3 = 'item_list';
  $html       = getShortTags($tagName3, $attrName3, $attrValue3, $url); 
  
  function getShortTags($tagName, $attrName, $attrValue, $url = "", $exclAttrValue = 'itemTitle') {
  
      $dom = $this-&gt;getDom($url);
  
      $html                 = '';
      $domxpath             = new \DOMXPath($dom);
      $newDom               = new \DOMDocument;
      $newDom-&gt;formatOutput = true;
  
      $filtered = $domxpath-&gt;query(" //" . $tagName . "[@" . $attrName . "='" . $attrValue . "']/descendant::text()[not(parent::span/@" . $attrName . "='" . $exclAttrValue . "')] ");
      $i        = 0;
      while ($myItem   = $filtered-&gt;item($i++)) {
          $node   = $newDom-&gt;importNode($myItem, true);
          $newDom-&gt;appendChild($node); 
      }
      $html = $newDom-&gt;saveHTML();
      return $html;
  }
  </code></pre>
  
  <p>What am I getting?</p>
  
  <pre><code>Status\nSold\nVraagprijs\n389.000\nIn overleg\n....
  </code></pre>
  
  <p>Desired output anything like:</p>
  
  <pre><code>$html = array("Status" =&gt; "Sold", "Vraagprijs" =&gt; "389.000", "Aanvaarding" =&gt; "In overleg", ...)
  </code></pre>
  
  <p>Is there a way to "loop" through the itemList and get each itemName and itemValue into an associative array?</p>