假设我有这个数组:
Array
(
[Europa] => Array
(
[country] => France
[capital] => Paris
),
(
[country] => Spain
[capital] => Madrid
)
[Asia] => Array
(
[country] => Russia
[capital] => Moscow
)
)
如何计算Asia
或Europa`中包含的项目数?
谢谢。
答案 0 :(得分:0)
假设
$myArray= [
'Europa' => [
'country' => France
'capital' => Paris
],
[
'country' => Spain
'capital' => Madrid
],
'Asia' => [
'country' => Russia
'capital' => Moscow
],
];
您可以基于索引使用count()
$numEuropa = count($myArray['Europa']);
$numAsia = count($myArray['Asia']);
答案 1 :(得分:0)