Copyright © tutorialspoint.com

PHP Function array_count_values()

previous
Advertisements

Syntax

array array_count_values ( array $input );

Definition and Usage

Returns an array using the values of the input array as keys and their frequency in input as values.

Paramters

ParameterDescription
inputThe array of values to count

Return Values

Returns an assosiative array of values from input as keys and their count as value.

Example

Try out following example:

<?php
$input_array = array("orange", "mango", "banan", "orange" );
print_r(array_count_values($input_array));
?> 

This will produce following result:

Array ( [orange] => 2 [mango] => 1 [banana => 1 )
previous

Copyright © tutorialspoint.com