Answers for "php associative array count the number of occurrence of array by key s"

PHP
3

php count array elements with specific key

$cnt = count(array_filter($array,function($element) {
  return $element['your_key']=='foo';
}));
Posted by: Guest on July-13-2020
0

php count occurrences of string in array

$array = array('', '', 'other', '', 'other');

$counter = 0;
foreach($array as $value)
{
  if($value === '')
    $counter++;
}
echo $counter;
Posted by: Guest on October-08-2021

Code answers related to "php associative array count the number of occurrence of array by key s"

Browse Popular Code Answers by Language