title: How to parse HTML in PHP?
body: <p>I know we can use <a href="http://www.php.net/manual/en/book.dom.php" rel="noreferrer">PHP DOM</a> to parse HTML using PHP. I found a lot of questions here on Stack Overflow too. But I have a specific requirement. I have an HTML content like below</p>
  
  <pre><code>&lt;p class="Heading1-P"&gt;
      &lt;span class="Heading1-H"&gt;Chapter 1&lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="Normal-P"&gt;
      &lt;span class="Normal-H"&gt;This is chapter 1&lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="Heading1-P"&gt;
      &lt;span class="Heading1-H"&gt;Chapter 2&lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="Normal-P"&gt;
      &lt;span class="Normal-H"&gt;This is chapter 2&lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="Heading1-P"&gt;
      &lt;span class="Heading1-H"&gt;Chapter 3&lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="Normal-P"&gt;
      &lt;span class="Normal-H"&gt;This is chapter 3&lt;/span&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>I want to parse the above HTML and save the content into two different arrays like:</p>
  
  <p><code>$heading</code> and <code>$content</code></p>
  
  <pre><code>$heading = array('Chapter 1','Chapter 2','Chapter 3');
  $content = array('This is chapter 1','This is chapter 2','This is chapter 3');
  </code></pre>
  
  <p>I can achieve this simply using jQuery. But I am not sure, if that's the right way.
  It would be great if someone can point me to the right direction.
  Thanks in advance.</p>