我有一個名爲$test_data
的數組,我想更新一個密鑰['test_duration']
。但是,我無法執行此更新。請看下面的數組:爲什麼數組密鑰的值沒有得到更新?
Array
(
[0] => Array
(
[test_id] => 1116
[test_name] => ques stats
[test_no_questions] => 50
[test_duration] => 28800
)
[1] => Array
(
[test_id] => 1112
[test_name] => Own Test 1
[test_no_questions] => 2
[test_duration] => 7200
)
)
我嘗試以下,但它沒有工作:
foreach ($test_data as $key => $value) {
$value[$key]['test_duration'] = ConvertTimeStampToTimeFormate($value['test_duration']);
}
如果我這樣操作後打印的陣列,它是作爲之前打印同一陣列。這裏有什麼問題?
RTFM:http://www.php.net/manual/en/control-structures .foreach.php – CBroe