I need to add a <p> tag to the beginning of each array value and a closing </p> tag at the end of each array value.
If there is a [ or ] delimiter then they need to be replaced with <p class="myclass">
Array
(
[0] => [This is a line of text
[1] => and another
[2] => and yet another.] [This is another line of text
[3] => and another
[4] => and another] [OK, so you get the idea.
)
The above array should become:
Array
(
[0] => <p class="myclass">This is a line of text</p>
[1] => <p>and another</p>
[2] => <p>and yet another.</p> <p class="myclass">This is another line of text</p>
[3] => <p>and another</p>
[4] => <p>and another</p> <p class="myclass">OK, so you get the idea.</p>
)
The question is: Using a foreach loop, how do I get from the first array to the second array?
See Live Example