title: How to parse html and return the elements value in an array in order of apperance in the html?
body: <p>This code uses <a href="http://querypath.org" rel="nofollow">http://querypath.org</a> and <a href="http://php.net/manual/en/class.domelement.php" rel="nofollow">http://php.net/manual/en/class.domelement.php</a></p>
  
  <p>What I would like to do is get all tags in $types and go through $html and save the output to an array in order of that tags appearance in html
  e.g </p>
  
  <pre><code>.imageBlock,h1,h2,p,h5,h1,h2,p,.imageblock,h4 
  </code></pre>
  
  <p>this is the order the final array must have how would I do this?
      
  
  <pre><code>$html = &lt;&lt;&lt;html
  &lt;section&gt;
      &lt;div class=" imageBlock" style="background: url('1.jpg');"&gt;&lt;/div&gt;   
  &lt;div&gt;
      &lt;h1&gt;H1 .1&lt;/h1&gt;
      &lt;h2&gt;H2. 1&lt;/h2&gt;
      &lt;p&gt;p .1&lt;/p&gt;
  &lt;/div&gt;      
   &lt;h5&gt;Here is an H5&lt;/h5&gt;
  &lt;div&gt;
      &lt;h1&gt;H1 .2&lt;/h1&gt;
      &lt;h2&gt;H2. 2&lt;/h2&gt;
      &lt;p&gt;p .2&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="imageBlock" style="background: url('2.jpg');"&gt;&lt;/div&gt;    
  
  &lt;h4&gt;Test&lt;/h4&gt;
  &lt;section&gt;
  html;
  
  $types = ['h1','h2','h3','h4','h5','h6','p', '.imageBlock'];
  
  foreach($types as $type) {
      //Create a varible for each tag
      ${"$type"} = htmlqp($html, $type);
  }
  
  foreach($types as $type) {
      $types = (${"$type"}); //Easier to use varible
      $nodes = []; //Array to hold elements in order of appperance not sure if in correct place?
      foreach($types as $tag) {
          if($types-&gt;length !== 0) {
              //Show all elements
              for($i = 0 ; $i&lt; $types-&gt;length; $i++) {
                  echo $type;
                  var_dump($types-&gt;get()[$i]);
              }
          }
      }
  }
  
  
  ?&gt;
  </code></pre>