0

I have a long string which should be seperated on multiple delimiters. The delimiters are in an array. The delimiters are groups of words. Is the some nice short version to do that? The result should be in an array in the end.

Thanks!

hakre
  • 193,403
  • 52
  • 435
  • 836
EOB
  • 2,975
  • 17
  • 43
  • 70

1 Answers1

2

Use preg_split function. It accepts regex as first argument and your regex can OR multiple expressions

Vadim Gulyakin
  • 1,415
  • 9
  • 7
  • Yeah, but my delimiters are words, like *this is a delimiter*. How would that look like? – EOB Jan 13 '12 at 15:59
  • Delimiters containing multiple words are fine. You should build regex from your array as `this is a delimiter|this is a another delimiter|this is a third delimiter` – Vadim Gulyakin Jan 13 '12 at 16:59