Re: Most popular word sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, 13 July 2011 at 23:30, Ron Piggott wrote:

> Is it possible in PHP to sort an array by most frequently occurring word / phrase, 2nd most frequently occurring, third, etc.
> 
> An example array is:
> 
> Array ( [1] => Parable [2] => Mustard [3] => Seed [4] => Parable [5] => Good [6] => Samaritan [7] => Parable [8] => Workers [9] => Vineyard [10] => Parable [11] => Lost [12] => Sheep [13] => Parable [14] => Lost [15] => Coin [16] => Parable [17] => Prodigal [18] => Parable [19] => Sower [20] => Parable [21] => Weeds [22] => Parable [23] => Hidden [24] => Treasure [25] => Parable [26] => Parable [27] => Wedding [28] => Banquet [29] => Parable [30] => Virgins [31] => Parable [32] => Bags [33] => Gold [34] => Parable [35] => Yeast ) 
> 
> The most popular word is “Parable”. I would like it to be the first result. 
> Then the second most popular word is “Lost”. 
> Then all the remaining words are only used once.

If I'd have spent two minutes reading the array section of the manual first I'd have found this... http://php.net/array_count_values

But I didn't, so I wrote this... https://gist.github.com/1081541

Meh!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux