Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

PHP Function array_count_values()


previous

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



  

Advertisement

Online Image Processing

Indian Baby Names