PHP/Data Structure/array count values — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
array_count_values demo
<?php
$states = array("Ohio","Iowa","Arizona","Iowa","Ohio");
$stateFrequency = array_count_values($states);
print_r($stateFrequency);
?>
array_count_values() function counts the frequency of the values.
Its syntax is: array array_count_values (array array);
<?
$states = array("OH", "OK", "CA", "PA", "OH", "OH", "PA", "AK");
$state_freq = array_count_values($states);
print_r( $state_freq );
?>
Counts all the values of an array with array array_count_values (array input)
<?
$array = array(1, "hello", 1, "world", "hello");
array_count_values($array);
?>