|
Posted by Philipp Grassl on 05/22/07 10:42
Hm, you mean like
---
$n=2;
preg_replace("'\<[^\>]*\>[^\<]*\<\/[^\>]*\>'si", "", $someBigString, $n);
---
?
Alternatively, if you'd like to limit the Tag to a specific one you
could also do
---
$n=2;
preg_replace("'\<someTag\>[^\<]*\<\/someTag\>'si", "", $someBigString, $n);
---
Or did I misunderstand you here...
Peter Parker schrieb:
> 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.
>
>
Navigation:
[Reply to this message]
|