title: Prepend HTML text using DOMDocument without parent container
body: <p>Let's say I have <code>&lt;p&gt;Text&lt;/p&gt;</code></p>
  <p>I'd like to create a function using DOMDocument to be able to insert text, eg:</p>
  <pre><code>insertText('&lt;p&gt;Text&lt;/p&gt;', '&lt;strong&gt;1.&lt;/strong&gt; ')
  </code></pre>
  <p>So that the result was <code>&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Text&lt;p&gt;</code></p>
  <p>I'm already accessing this paragraph tag, so I think I'm almost there, I just cannot figure out how to append plain text that can be read as HTML</p>
  <pre><code>$dom = new DOMDocument();
  $question_paragraphs = array();
  $dom-&gt;loadHTML($str);
  $par = $dom-&gt;getElementsByTagName('p');
  if ($par-&gt;length == 1) {
      $par-&gt;item(0)-&gt;setAttribute(&quot;class&quot;, &quot;first last&quot;);
  ###
  ### How do I do this here?
  ###
  }
  </code></pre>
  <p>Is it possible to inject text this way?</p>