我需要编辑多维数组中的最后一项
Array
(
[0] => Array
(
[column] => Country
[operator] => =
[value] => 2
[total] => 0
)
[1] => Array
(
[column] => State
[operator] => =
[value] => 1
[total] => 0
)
)
仅编辑最后一个数组的total
字段
$count = count( $array);
$ultimaChave[$count]['total'] = 55;
答案 0 :(得分:2)
PHP使用基于零的索引,因此您只需要获取数组长度减去一即可:
$count = count($array);
$array[$count-1]['total'] = 55;