in PHP, how to append incremental value to each tag
<p>I have a bunch of <code>&lt;P&gt;</code> tags in an HTML file that I would like to append a unique value to, for example, my HTML file has the following (i've dumped this HTML file into a PHP variable using <code>file_get_contents</code>):</p>

<pre><code>&lt;P&gt; ... data ... &lt;/P&gt;
&lt;P&gt; ... data ... &lt;/P&gt;
&lt;P&gt; ... data ... &lt;/P&gt;
&lt;P&gt; ... data ... &lt;/P&gt;
&lt;P&gt; ... data ... &lt;/P&gt;
</code></pre>

<p>I would like to change it so it reads this instead:</p>

<pre><code>&lt;P id='unique1'&gt; ... data ... &lt;/P&gt;
&lt;P id='unique2'&gt; ... data ... &lt;/P&gt;
&lt;P id='unique3'&gt; ... data ... &lt;/P&gt;
&lt;P id='unique4'&gt; ... data ... &lt;/P&gt;
&lt;P id='unique5'&gt; ... data ... &lt;/P&gt;
</code></pre>

<p>Since this is a regular HTML file, there are other tags that may reside in the file as well (such as <code>&lt;HTML&gt;</code>, <code>&lt;HEAD&gt;</code>, <code>&lt;STYLE&gt;</code>, <code>&lt;BODY&gt;</code>, etc., but I want to append a unique id to ALL <code>&lt;P&gt;</code> tags</p>
