On Monday 24 February 2003 16:12, Kevin Waterson wrote: > I wish to fine the most occurringest value in an array. eg: > > $arr = array('dog', 'cat', 'dog', 'zebra', 'cat', 'dog', 'dog', 'dog'); > > if I use array_count_values it gives "dog => 5" > I would like to get 'dog' and '5' into a $variable.
$arr = array('cat', 'dog', 'cat', 'dog', 'zebra', 'cat', 'dog', 'dog', 'dog'); $doo = array_count_values($arr); arsort($doo); $dah = each ($doo); $creature = $dah[0]; $count = $dah[1]; print "$creature appeared $count times!"; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* "You shouldn't make my toaster angry." -- Household security explained in "Johnny Quest" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php