title: Get all itemprop and itemprop depths
body: <p>I have this code and it works more or less, the problem is some of them are empty and in wrong place in the array, and inside offers there's 3 other itemprops.</p>
  
  <p>I dont want to hard code because I'm going to use it on multi websites.</p>
  
  <pre><code>function get_product_itemprop($url){
  $url = file_get_contents($url);
  $d = new DOMDocument();
  $d-&gt;loadHTML($url);
  $xpath = new DOMXPath($d);
  $nodes = $xpath-&gt;query('//*[@itemprop]'); 
  
  $new_data = array();
  foreach ($nodes as $node) { 
      $new_data[$node-&gt;getAttribute("itemprop")] = trim(preg_replace('/\s+/', ' ',$node-&gt;nodeValue));
  }
  return $new_data;
  
  }
  </code></pre>
  
  <p>Result of the function </p>
  
  <pre><code>    array(8) {
    ["breadcrumb"]=&gt;
    string(38) "Home Atomizers &amp; Coils Amor Mini coils"
    ["name"]=&gt;
    string(15) "Amor Mini coils"
    ["sku"]=&gt;
    string(5) "CO815"
    ["offers"]=&gt;
    string(8) "$ 13.99"
    ["price"]=&gt;
    string(0) ""
    ["priceCurrency"]=&gt;
    string(0) ""
    ["availability"]=&gt;
    string(0) ""
    ["url"]=&gt;
    string(0) ""
    }
  </code></pre>
  
  <p>On <a href="http://search.google.com/structured-data/testing-tool" rel="nofollow noreferrer">http://search.google.com/structured-data/testing-tool</a> I get all the itemprops and I want a similar structure they done but with an array: </p>
  
  <p><img src="https://i.imgur.com/KbNRvnG.jpg" alt="http://imgur.com/KbNRvnG"></p>