Answers for "how to count specific number of elements in an array php"

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
8

get array length using php

// using count() we can get proper length of the array
$names = array("Ankur","Raj","Ram","Suresh");
// pass array into count() as parameter it will return array length
echo count($names);

// output : 4
Posted by: Guest on June-03-2020

Code answers related to "how to count specific number of elements in an array php"

Browse Popular Code Answers by Language