Re: Counting the occurences of items in an array

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

 



Dotan Cohen wrote:
Has this wheel been invented, but simpler? I've an array of words that
I'd like to know how many occurences of each there are. For instance:
$fruits = array(
   "lemon",
   "orange",
   "banana",
   "apple",
   "orange",
   "banana",
   "orange"    );

And I'd like to create this:
$fruit_count = array(
   "lemon" => 1,
   "orange" => 3,
   "banana" => 2,
   "apple" => 1    );


check
http://in2.php.net/manual/en/function.array-count-values.php



--
Thanking You

Sumeet Shroff
http://www.prateeksha.com
Web Designers and PHP / Mysql Ecommerce Development, Mumbai India

--
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