array_count_values() function in php
×


array_count_values() function in php

0 556

array_count_values() function of PHP is used to count all the items of an array means it count the number of occurrence of a value into an array. It is an inbuilt function of PHP.

It returns an associative array which contains array values as keys and their occurrences as values.

Syntax
array_count_values ($array);

Here

$array represents an array.


Example:

<?php
$arr=array("Mango","Orange","Pear","Mango","Banana","Apple");
$new_arr=array_count_values($arr);
echo "<pre>";
print_r($new_arr);
?>

Output:




Share:


Leave a Reply


Comments
    Waiting for your comments