How do I include the split delimiter in results for preg_split()?

Viewed 17934

I have this simple pattern that splits a text into periods:

$text = preg_split("/[\.:!\?]+/", $text);

But I want to include . : or ! at the end of the array items.

That is, now for "good:news.everyone!" I have:

array("good", "news", "everyone", "");

But I want:

array("good:", "news.", "everyone!", "");
2 Answers
Related