title: PHP WordPress Foreach H2 Heading in HTML
body: <p>How can I achieve something where I can use a PHP foreach loop which will loop through`the_content() of a WordPress post/page, find H2 tags and wrap each H2 section in a div?</p>
  
  <p>I want to alternate between:</p>
  
  <pre><code>&lt;div class="content animate-on-view fadeInUp wrap"&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;div class="content even animate-on-view fadeInUp wrap"&gt;
  </code></pre>
  
  <p>But I'm not sure how to achieve this. How would I get the post content and find the H2 tags and then wrap the H2 sections (all the content up until the next H2 tag or the end of the post) in the above divs?</p>
  
  <p>Thanks :)</p>