Reputation: 209
I need to edit the last item in a multidimensional array
Array
(
[0] => Array
(
[column] => Country
[operator] => =
[value] => 2
[total] => 0
)
[1] => Array
(
[column] => State
[operator] => =
[value] => 1
[total] => 0
)
)
Only edit the total
field of the last array
$count = count( $array);
$ultimaChave[$count]['total'] = 55;
Upvotes: 0
Views: 30
Reputation: 22911
PHP uses zero based indices, so you simply need to grab the length of the array minus one:
$count = count($array);
$array[$count-1]['total'] = 55;
Upvotes: 2