saveHTML() in php adds unwanted tags
<p>I've been in some trouble the past 2 weeks, I've spend much time researching this, no one else seems to have the same problem as I have. Now,  I have a file with <code>html</code> and <code>php</code> in it. I run that trough a simple code, that uses <code>DOM</code> then puts the result into a other file. </p>

<p>The html file:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;?php 
        if($_POST){
            $array = array(
                'username' =&gt; array(
                    'required' =&gt; true
                    ),    
                'password' =&gt; array(
                    'required' =&gt; true,
                    )
                );
         }
    ?&gt;
&lt;/head&gt;
&lt;body&gt; 
     &lt;p&gt; Html works just fine &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Now I run this through a simple program, save it with the function <code>$dom-&gt;saveHTML()</code> and then put the result in another file with <code>file_put_contents()</code>.  It works fine, until I have an array like shown above, then it adds this into the php:</p>

<p><a href="https://i.stack.imgur.com/yLRle.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yLRle.png" alt="Image op the &lt;code&gt;var_dump&lt;/code&gt; result"></a></p>

<p>Yes, I have tried to add those things when loading the file into the DOM, but, it never removes the weird <code>&lt;p&gt;</code> tag, it just doesn't GO!</p>

<p><strong>More explanation:</strong> Ok, so. I have a file, the first file you see. I load that in a string, I then <code>$dom-&gt;loadHTML($filestring)</code>. So, I loaded the file in <code>dom</code>. If I now save it with <code>$dom-&gt;saveHTML()</code> and put that result in a different file, I get this weird thing in my array, only with that kind of array ( You can see it on the 4th line of the picture, I <code>var_dumped</code> the string that I put into the file). Hopefully this makes more sense now.</p>

<p>I hope someone can help me out of my frustration, thanks for your time already. </p>