我有一个数组
Array
(
[array_name_1] => Array
(
[0] => 1
[1] => 1
[2] => 1
[3] => 1
[4] => 1
)
[array_name_2] => Array
(
[5] => 1
[6] => 1
[7] => 1
[8] => 1
[9] => 1
[10] => 1
)
)
我想合并并计算上面的数组数,以使其成为
array
(
[array_name_1] => 5
[array_name_2] => 6
)
任何人都可以帮助提供解决方案吗?谢谢
答案 0 :(得分:0)
只需使用foreach循环
$finalArr = [];
foreach($yourMainArr as $key => $arr){
$finalArr[$key] = count($arr);
}
print_r($finalArr);