Find <p> tag in a very long text
<p>I have a very long HTML text in which I want iterate id value of a <code>p</code> tag in PHP. My original string:</p>

<pre><code>$mystring="
&lt;p&gt; my very long text with a lot of words ....&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt; my other paragraph with a very long text ...&lt;/p&gt;
(...)
";
</code></pre>

<p>Result that I want:</p>

<pre><code>$myparsestring= "
&lt;p id=1&gt;my very long text with a lot of words ....&lt;/p&gt;
&lt;p id=2&gt; my other paragraph with a very long text ...&lt;/p&gt;
";
</code></pre>

<p>As you can see, I can use <code>getElementsByTagName ()</code> and regex (may be split).</p>

<p>What is your guidance to do this job?</p>
