Page 1 of 1

Edit array values [SOLVED]

Posted: Wed Apr 09, 2008 9:45 am
by aceconcepts
I have the following array structure:

Array ( [0] => Array ( [1] => Array ( [0] => 1 [1] => 4 ) ) )

What I want to be able to do is add values to the third nested array.

How would I do this?

Re: Edit array values

Posted: Wed Apr 09, 2008 10:25 am
by EverLearning
if you want to add values to the third nested array, so it looks, for example, like this

Code: Select all

array
  0 => 
    array
      1 => 
        array
          0 => int 1
          1 => int 4
          2 => string 'asdfadsfa' (length=9)
          'test' => string 'testxxxx' (length=8)
 
do this:

Code: Select all

$array[0][1][] = 'asdfadsfa'; // if the key value doesn't matter 
$array[0][1]['test'] = 'testxxxx'; // if you want to set a specific key

Re: Edit array values

Posted: Wed Apr 09, 2008 10:33 am
by aceconcepts
Nice one, i'll give it a whirl :D

Re: Edit array values

Posted: Wed Apr 09, 2008 10:50 am
by aceconcepts
It worked - excellent.

Thank you.