$calls = [
['prefix' => '+57'],
['prefix' => '+268'],
['prefix' => '+972'],
['prefix' => '+972'],
['prefix' => '+33'],
['prefix' => '+33'],
['prefix' => '+972'],
['prefix' => '+509'],
['prefix' => ''],
['prefix' => '+33'],
['prefix' => '+268'],
['prefix' => '+57'],
];
function calcPrefixStat($calls) {
$stat = [];
foreach($calls as $call) {
if (!array_key_exists($call['prefix'], $stat)) {
$stat[$call['prefix']] = 0;
}
$stat[$call['prefix']]++;
}
return $stat;
}
var_dump(calcPrefixStat($calls));
/*
array(6) {
["+57"]=>
int(2)
["+268"]=>
int(2)
["+972"]=>
int(3)
["+33"]=>
int(3)
["+509"]=>
int(1)
[""]=>
int(1)
}
*/