我有一個多維數組,我會有多個數組。其中一些數組也包含多個數組,並且我想要統計第二個數組中有多少個數組(日期)。如何計算多維數組中有多少個數組具有相同名稱的多維數組?
這是多維數組結構的一個例子:
$_SESSION['final_shipping'][04/03/2010][book]
$_SESSION['final_shipping'][04/12/2010][magazine]
$_SESSION['final_shipping'][04/12/2010][cd]
這是我目前使用的計算有多少第二陣列(帶有日期)存在的foreach語句。
foreach($_SESSION['final_shipping'] as $date_key => $date_value) {
foreach ($date_value as $product_key => $product_value) {
echo 'There are ' . count($date_key) . ' of the ' . $date_key . ' selection.<br/>';
}
}
它當前輸出該:
有所述04/03/2010選擇的1。
2010年4月12日的選擇中有1個。
2010年4月12日的選擇中有1個。
我會把它想輸出這樣的:
還有的選擇04/03/2010 1。
2010年4月12日的選擇中有2個。
我太親近了。非常感謝! – zeckdude 2010-04-07 10:14:34