Page 1 of 1

String to Array

Posted: Sat Feb 14, 2009 12:26 am
by jwerre
Is there a simple way to convert a paragraph of text into an array of sentences?

How would I turn this:
$paragraph = "Sentence number one. Sentence number two. Sentence number three."

...into this:
Array([0]=>"Sentence number one." [1]=>"Sentence number two."[3]=>"Sentence number three.")

Isn't there a split method or something in php?

Re: String to Array

Posted: Sat Feb 14, 2009 1:17 am
by requinix
It can get really complicated really quickly.

If you don't have words like "Mr." or numbers like "1.2" then you can explode on a period. Otherwise you're probably stuck with regular expressions.
(PS: We have a Regex forum.)