Page 1 of 1

spliting string by [stuff]

Posted: Sun Jul 30, 2006 10:38 am
by Erfangc
Say I have a string "hello world [stuff] //code source [/stuff] bla bla bla". How can I split this string each time the function encounters the stuff tag? So far I have tried split("[[stuff].[/stuff]]",$str) with no luck. I also tried several variations and the strtok() method.

Posted: Sun Jul 30, 2006 10:43 am
by feyd
explode() may be more easily handled.

Posted: Sun Jul 30, 2006 10:52 am
by Erfangc
feyd wrote:explode() may be more easily handled.
I need to open it on a [stuff] tag and a closing [/stuff] tag but explode only takes one separator.

Posted: Sun Jul 30, 2006 10:55 am
by feyd
you can call it on the resulting array elements.

Posted: Sun Jul 30, 2006 11:05 am
by Erfangc
feyd wrote:you can call it on the resulting array elements.
sounds like I'm gonna need a recurisve function.

EDIT: Nevermind, I think I found a non mind twisting way