View Single Post
Old 24th November 2005, 10:35 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Try this code:

PHP Code:
$str "This is your lucky day. If it is you lucky day then you are lucky.";

// prepare
$unique_words = array();
$words explode(" ",str_replace(".","",$str));
foreach (
$words as $word) {
   
$unique_words[strtolower($word)] = 0;
}
reset($words);
foreach (
$words as $word) {
   
$unique_words[strtolower($word)]++;
}

// display
foreach ($unique_words as $word=>$count) {
   echo 
"$word = $count<br>";

__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote