我保存多個數組內數組內數組怎麼算內部數組數如何算多陣列計數PHP
Array (
[0] => Array ([table] => items [sku] => LUDM15)
[1] => Array ([table] => items [sku] => SEZC64)
)
怎麼算內部數組數....
我保存多個數組內數組內數組怎麼算內部數組數如何算多陣列計數PHP
Array (
[0] => Array ([table] => items [sku] => LUDM15)
[1] => Array ([table] => items [sku] => SEZC64)
)
怎麼算內部數組數....
循環遍歷數組然後count
內陣列的長度:
$array = array(array('hi', 'hello'), array('hi', 'hello'), array('hi', 'hello'));
foreach ($array as $singleArray){
echo 'Count = ' . count($singleArray);
}
$mainArray = array (
[0] => array ([table] => items [sku] => LUDM15)
[1] => array ([table] => items [sku] => SEZC64)
)
foreach ($mainArray as $subArray){
echo count($subArray);
}
在foreach中你可以做任何你想要的單個子數的數量。
假設
$array1 is Array (
[0] => Array ([table] => items [sku] => LUDM15)
[1] => Array ([table] => items [sku] => SEZC64)
)
$count = array();
foreach ($array1 as $key => $value) {
$count[] = count($value);
}
所有計數值將存儲在計數陣列
使用用於循環來循環,並執行內部循環計數功能。 –