在特殊情况下,你可能只想统计数组的第一层,以确定你有多少条目,而它们还有 N 个键值对。
<?php
$data = [
'a' => [
'bla1' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
'bla2' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
'bla3' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
'bla4' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
],
'b' => [
'bla1' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
'bla2' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
],
],
'c' => [
'bla1' => [
0 => 'asdf',
1 => 'asdf',
2 => 'asdf',
]
]
];
$count = array_sum(array_values(array_map('count', $data)));
var_dump($count);
var_dump(count($data, 1));
?>