Ben böyle bir dizi var ki:
$array = array('', '', 'other', '', 'other');
Nasıl belirli bir değer ile sayı (örneğin boş) sayabilirsiniz?
And do it efficiently? (for about a dozen arrays with hundreds of elements each) This 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;
}
Bu durumda boş elemanların sayısı 3'tür.