"count how often a particular value appears in an array" Answer’s

0

PHP has a function called array_count_values for that.

Example:

<?php
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
?>

Output:

Array
(
    [1] => 2
    [hello] => 2
    [world] => 1
)
Wednesday, March 31, 2021
 
bumperbox
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share