Get a word list from a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scaryfast
Forum Newbie
Posts: 1
Joined: Wed Apr 07, 2004 3:46 pm

Get a word list from a string

Post by scaryfast »

Hey,

Im trying to obtain a list of words contained in a string, but I'm stuck!

Basically, I want something like an array, or comma delimited string with all the words separated, with no punctuation characters.

Im rubbish with preg and stuff like that, so any help would be brilliant...

Many thanks. :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

preg_split("/[^\w]+/",$string);
...should do it, I think.
Post Reply