faqts : Computers : Programming : Languages : PHP : Common Problems : Regular Expressions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 17 people (100%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How can I get all words from a sentence into an array?

Aug 7th, 1999 23:14
Nathan Wallace, Rasmus Lerdorf, Steve Edberg


How about:

    $regs = split("[^[:alpha:]]+",$terms);

And, if you want to use this to strip out punctuation from a sentence 
but leave contractions, etc in (eg; it's, doesn't, etc):

    $regs = split("[^[:alpha:]']+", $terms);