Forum Moderators: coopster

Message Too Old, No Replies

Explode on multiple strings?

         

dbzfyam

3:06 pm on Jan 29, 2009 (gmt 0)

10+ Year Member



Does anyone know of a way to explode on multiple strings? For example:

---
text text text text text
text text text
[table-01]

text text text
text text text text text text
text text text text
[table-02]

text text text
---

I need to explode on "[table-01]" and on "[table-02]" (I have these in a seperate array and they are variable. There might be 2 tables, might be 20), so I keep the text blocks in a array. Due to a limitation in a class I'm using, I can't simply use str_replace to insert the tables, so I need to run the resulting array through a loop and echo the tables inbetween.

Thanks in advance for the suggestions!
Stefan

eelixduppy

6:30 pm on Jan 29, 2009 (gmt 0)



You can use preg_split here.

$chunks = [url=http://www.php.net/preg-split]preg_split[/url]("/\[table-\d+\]/", $string);

Try something like that and see if it helps. :)