我已經設置了關聯數組的數組(與測試虛擬數據)附加陣列的方法:比較像這樣在foreach循環
// To hold dropdown filter options
$results['filters'] = array('Client' => array(array('a' => '1')),
'Project' => array(array('b' => '2')),
'Status' => array(array('c' => '3')),
'User' => array(array('d' => '4'))
);
誰能告訴我,爲什麼這個工程:
// Add 'All' option to the top of each filter dropdown
foreach($results['filters'] as $filter_key => $filter_value) {
$results['filters'][$filter_key][] = array('name' => 'All');
}
但這並不:
// Add 'All' option to the top of each filter dropdown
foreach($results['filters'] as $filter_key => $filter_value) {
$filter_value[] = array('name' => 'All');
}
當我做print_r($results)
的循環裏面一個ppears正在工作(將行附加到現有數據),但在循環之外檢查它看起來像循環對陣列沒有影響。
感謝
嗯謝謝你的快速回答,現在變得非常有意義。我很驚訝我沒有遇到過這樣的事情。 – BennyTheBen 2013-05-05 16:15:02