Count matching occurrences in php array

Count matching occurrences in php array
Count matching occurrences in php array

You can Count matching occurrences in php array using php array function array_count_values()

Syntax:

array array_count_values ( array $array )

array_count_values() returns an array using the values of array as keys and their frequency in array as values.

 Example:-

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

Above code will output:

Array([1]=>2 [roopendra] => 2 [php] => 1 )
(Visited 149 times, 3 visits today)
Verified by MonsterInsights