see: array_count_values
Like:
$occurences = array_count_values($items);
print_r($occurences);
Output:
Array
(
[4] => 3
[2] => 3
)
Usage:
echo $occurences[4]; // outputs 3
More Related Contents:
- What is the best way to loop through this array in PHP?
- PHP Foreach Pass by Reference: Last Element Duplicating? (Bug?) [duplicate]
- How do you remove an array element in a foreach loop?
- PHP hierarchical array – Parents and childs
- Looping a multidimensional array in php
- Checking if array is multidimensional or not?
- PHP foreach loop through multidimensional array [duplicate]
- Loop a multidimensional array and only print two specific column values per row
- case-insensitive array_unique
- Insert elements from one array (one-at-a-time) after every second element of another array (un-even zippering)
- How to set an option from multiple options or array with different values to views as selected in select box using PHP
- PHP array printing using a loop
- Twig for loop for arrays with keys
- PHP create new array by value
- Get first and second element of array [duplicate]
- PHP Multidimensional associative array to HTML table
- count how many duplicate keys are in array of objects?
- How to add elements to an empty array in PHP?
- PHP Sort Array By SubArray Value
- Using a string path to set nested array data [duplicate]
- How to get random value out of an array?
- How can I echo or print an array in PHP?
- Flatten multidimensional array concatenating keys [duplicate]
- Search and replace multiple values with multiple/different values in PHP5?
- PHP Recursively unset array keys if match
- $_POST max array size
- for loop vs while loop vs foreach loop PHP
- Efficiency of using foreach loops to clear a PHP array’s values
- how to sort a multidemensional array by an inner key
- How are associative arrays implemented in PHP?