title: DOMDocument insert <h1> tag before </body> tag
body: <p>How can I insert an <code>&lt;h1&gt;</code> tag right before closing <code>&lt;/body&gt;</code> tag?</p>
  
  <pre><code>$html = '
      &lt;html&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;span&gt;Blalala&lt;/span&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  ';
  
  $dom = new DOMDocument();
  $dom-&gt;loadHtml($html);
  //$body= $dom-&gt;getElementsByTagName('body');
  //Somehow insert h1 tag before &lt;/body&gt; tag
  echo $doc-&gt;savehtml($html);
  </code></pre>