Page 1 of 1

Pulling a certain word out of a bunch of text?

Posted: Mon Mar 31, 2008 8:42 am
by Dale
I was just wondering how or if not how, what function, to use to basically read some text and extract one certain word from it and put it into an array?

For example...

I have my text (as, lets say, a varible)
Hello everyone, my name is a name and I was just hoping that you like it... obviously you probably don't. Oh well.
Then I want it (somehow) to allow me to select a word, for example "name" and return me with each occurence as an array.

Code: Select all

Array (
    [0] = "name",
    [1] = "name"
)
:D

Re: Pulling a certain word out of a bunch of text?

Posted: Mon Mar 31, 2008 9:29 am
by aceconcepts
go to: http://uk.php.net/str_word_count

use the integer result within a for loop and create the array.