I have a string that is something like this:
$str="
<code>
lol
test
</code>
test";
I want to trim the text that is within the tags so that I end up with this:
$str="
<code>lol
test</code>
test";
Is there a way that I can split this out in to a 3 array pieces and so a simple trim() on the text in the middle?
many thanks
This should do it. What it does is looks for a
<tag>followed by any number of spaces and trims until it finds another non-space character. It then removes any number of spaces before a closing</tag>.See it in action: http://codepad.org/Stmd32QL
Edit
This would look for only
<code>tags.