php - Count number of values in array with a given value -


say have array this:

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

how can count number given value (in example blank)?

and efficiently? (for dozen arrays hundreds of elements each) example times out (over 30 sec):

function without($array) {     $counter = 0;     for($i = 0, $e = count($array); $i < $e; $i++) {         if(empty($array[$i])) {             $counter += 1;         }     }     return $counter; } 

in case number of blank elements 3.

how using array_count _values array counted you?


Comments