我有一个多维数组,我想替换其中的timestamp
字段..
Array
(
[new_messages] => 0
[0] => Array
(
[id] => 42
[sender] => 4
[receiver] => 4
[message] => Test
[timestamp] => 1368178683
[read] => 1
[s_deleted] => 0
[r_deleted] => 0
)
[1] => Array
(
[id] => 44
[sender] => 4
[receiver] => 4
[message] => test2
[timestamp] => 1368181485
[read] => 1
[s_deleted] => 0
[r_deleted] => 0
)
)
我跑:
foreach ($messageArray as $key => $row) {
$orderByDate[$key] = $row['timestamp'];
$newTimestamp = date("d-M-Y H:i:s", $row['timestamp']);
$messageArray[$key]['timestamp'] = $newTimestamp;
}
它确实有效,可以替换它,但我收到警告:
警告:不能将标量值用作数组
为什么?以及如何解决?