Replacing values in an array
<p>I need to add a <code>&lt;p&gt;</code> tag to the beginning of each array value and a closing <code>&lt;/p&gt;</code> tag at the end of each array value.</p>

<p>If there is a <code>[</code> or <code>]</code> delimiter then they need to be replaced with <code>&lt;p class="myclass"&gt;</code></p>

<pre><code>Array
(
    [0] =&gt; [This is a line of text
    [1] =&gt; and another
    [2] =&gt; and yet another.] [This is another line of text
    [3] =&gt; and another
    [4] =&gt; and another] [OK, so you get the idea.
)
</code></pre>

<p>The above array should become:</p>

<pre><code>Array
(
    [0] =&gt; &lt;p class="myclass"&gt;This is a line of text&lt;/p&gt;
    [1] =&gt; &lt;p&gt;and another&lt;/p&gt;
    [2] =&gt; &lt;p&gt;and yet another.&lt;/p&gt; &lt;p class="myclass"&gt;This is another line of text&lt;/p&gt;
    [3] =&gt; &lt;p&gt;and another&lt;/p&gt;
    [4] =&gt; &lt;p&gt;and another&lt;/p&gt; &lt;p class="myclass"&gt;OK, so you get the idea.&lt;/p&gt;
)
</code></pre>

<p>The question is: Using a foreach loop, how do I get from the first array to the second array?</p>
