Personally I would just use something like explode(), eg:
$sentence = "I am a PHP newbie";
$split_sentence = explode(' ', $sentence);
You could then reference the words thus:
$split_sentence[0] -> I
$split_sentence[1] -> am
$split_sentence[2] -> a
$split_sentence[3] -> PHP
$split_sentence[4] -> newbie
Or add print_r($split_sentence) to see the output.
Each() works if you've already gotten the words into an array such as that above, but you
need to get them there first.
|
Ahh ....
$foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each($foo);
print_r($bar);
|