I have
$statement = Array
(
[0] => Array
(
[red] => 06-01-2012
[green] => 436
[blue] => MEDIA
[black] => 2006
)
[1] => Array
(
[red] => 06-01-2012
[green] => 430
[blue] => MEDIA
[black] => 2007
)
);
And I want to add [flex] => 1 into array 1 by using something like $statement[1]. I have tried with array merge but they have combined array 0 and 1. Basically I want to add to the latest one.
if i understood you, try this:
$statement[count($statement)-1]['flex'] = 1;
<?php
$statement = array(
array(
"red" => 06-01-2012,
"green" => 436,
"blue" => "MEDIA",
"black" => 2006
)
,array(
"red" => 06-01-2012,
"green" => 436,
"blue" => "MEDIA",
"black" => 2006
)
);
echo "<pre>";
print_r($statement); //first
$statement[1]["flex"] = 1;
print_r($statement); //second
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With