3

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.

1

2 Answers 2

7

if i understood you, try this:

$statement[count($statement)-1]['flex'] = 1; 
Sign up to request clarification or add additional context in comments.

Comments

5
<?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 ?> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.