1 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個贊
如果你想計(jì)算DigitalAssets直接孩子你可以這樣做 count($array['DigitalAssets'])
這里有一些測試count應(yīng)該如何工作。
代碼是:
$test = array
(
'DigitalAssets' => array
(
0 => array(
'PartNumber' => '0276S-4',
'Link' => 'https://1ddf4b1b856a39e33863-d785dc0e3b62b5e0ef07f55db00b0659.ssl.cf2.rackcdn.com/Holley/0576s-4.jpg',
'AssetTypeCode' => 'P04',
'FileName' => '0576s-4.jpg',
'RecordModifiedDate' => '2020-05-13T18:59:10.28'
),
1 => array(
'PartNumber' => '0437S-4',
'Link' => 'https://1ddf4b1b856a39e33863-d785dc0e3b62b5e0ef07f55db00b0659.ssl.cf2.rackcdn.com/Holley/0437s-4.jpg',
'AssetTypeCode' => 'P04',
'FileName' => '0437s-4.jpg',
'RecordModifiedDate' => '2020-05-13T18:59:11.687'
),
2 => array
(
'PartNumber' => '0574S-4',
'Link' => 'https://1ddf4b1b856a39e33863-d785dc0e3b62b5e0ef07f55db00b0659.ssl.cf2.rackcdn.com/Holley/0574s-4.jpg',
'AssetTypeCode' => 'P04',
'FileName' => '0574s-4.jpg',
'RecordModifiedDate' => '2020-05-13T18:59:12.593'
)
)
);
echo count($test['DigitalAssets'])." ".count($test['DigitalAssets'], 0)." ".count($test['DigitalAssets'], 1);
exit();
結(jié)果在我的情況下: 3 3 18
這意味著在我的例子中,mode默認(rèn)情況下計(jì)數(shù)設(shè)置為 0,所以我將只計(jì)算第一級。如果我將模式設(shè)置為 1,我也會計(jì)算所有嵌套項(xiàng)目。這應(yīng)該為您解決問題。
- 1 回答
- 0 關(guān)注
- 115 瀏覽
添加回答
舉報(bào)