Pulling a certain word out of a bunch of text?

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
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Pulling a certain word out of a bunch of text?

Post 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

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

Post by aceconcepts »

go to: http://uk.php.net/str_word_count

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