What I'm trying to do is take in a variable of words and count how many times each word appears in the variable. Then I want the highest number found to be rank 0, the second highest to be rank 1, and so on. So far I have it finding how many times each word appears, but how would I go about adding the rank.
Something else I'm trying to do with is is get rid of the print_r function and just use echo with a loop.
Here's what I have so far.
$contents = "test test test test test one one one two two two two ato ato ato ato ato ato ato ato ato two three test test ato ato ato ato test test test test";
$array = explode(" ", $contents);
foreach($array as $value)
{
$array2[$value] = substr_count($contents,$value);
}
arsort($array2);
print_r($array2);
Any help would be appreciated.