★ wanayoo — archive 1999 http://www.php.net/manual/function.array-count-values.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Arrays
Quick Reference
Arrays
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this page
* array
* array_count_values
* array_diff
* array_flip
* array_intersect
* array_keys
* array_merge
* array_merge_recursive
* array_multisort
* array_pad
* array_pop
* array_push
* array_rand
* array_reverse
* array_shift
* array_slice
* array_splice
* array_unique
* array_unshift
* array_values
* array_walk
* arsort
* asort
* compact
* count
* current
* each
* end
* extract
* in_array
* key
* krsort
* ksort
* list
* natsort
* natcasesort
* next
* pos
* prev
* range
* reset
* rsort
* shuffle
* sizeof
* sort
* uasort
* uksort
* usort

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: array_count_values
View the source code for this pageSearch the site



Previous page
 array
 Updated
Wed, 18 Oct 2000
array_diff 
Next page


array_count_values

(PHP 4 >= 4.0b4)

array_count_values -- Counts all the values of an array

Description

array array_count_values (array input)

Array_count_values() returns an array using the values of the input array as keys and their frequency in input as values.

Example 1. Array_count_values() example


$array = array (1, "hello", 1, "world", "hello");
array_count_values ($array); // returns array (1=>2, "hello"=>2, "world"=>1)
      


User Contributed Notes: array_count_values


shevek@anarres.org
15-Feb-2000 10:45
One should theoretically be able to do a unique_array() by
$foo = array_keys(array_count_values($foo));



webmaster@battlereports.com
12-Jul-2000 02:00
This can be done in PHP3, but requires quite a few lines of code. Pretty simple though, just use a couple of arrays, one to keep track of the values, one to keep track of the counts.


 About Notes


Previous page
 array
 Updated
Wed, 18 Oct 2000
array_diff 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.