Re: counting array elements
| From: | janet at valade dot com | Date: | Mon, 24 Feb 2003 09:07:43 +0000 |
| Subject: | Re: counting array elements | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-136860@lists.php.net to get a copy of this message | ||
>In a message dated 2/24/2003 12:05:09 AM Pacific Standard Time,
>kevin@oceania.net writes:
>
>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.
array_count_values gives you an array with the values for keys and the count
of each value as the value ($array['dog']=5). You can then take that array
apart using extract.
Janet