Posted by Peter Parker on 05/22/07 06:16
What is the best way to delete tags n times from either the beginning or the
end of a String? For example, to delete "someString1" and "someString2"
along with surrounding <someTag>'s with n=2 and processing direction is from
beginning.
$someBigString="<someTag>someString1</someTag><someTag>someString2</someTag><someTag>someString3</someTag>";
I was thinking about use preg_replace() to replace "/</tag><tag/" with ""
but wasn't sure how, especially about the n times and direction of
processing. Any suggestion? Is using prreg_replace() the best way to
accomplish this task? Thanks.
[Back to original message]
|