Page 1 of 1

A Real Good Solution: MULTIDIMENSIONAL ARRAY

Posted: Thu Jun 15, 2006 2:43 pm
by poeta_eletrico
Hi,


I am struglins to find out the best way to APPEND values INDEXED by KEY in a 3 dimensional array.

I have previously the following array:

#part 1 of 2

Code: Select all

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [model 1] => 2006-01 => 31.8
                )

        )

    [1] => Array
        (
            [0] => Array
                (
                    [model 1] => 2006-02 => 134.56
                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [model 2] => 2006-02 => 746.85
                )

        )
#part 2

All I want is - use this first ARRAY - and compare to the second (not displayed here) and then by KEY reindex it (the above one)

For example:

Code: Select all

[0] => Array
        (
            [0] => Array
                (
                    [model 1] => 2006-01 => 31.8
                )

            [1] => Array
                (
                    [model 2] => 2006-01 => 55.8
                )

        )

(*) Here when compared to the other ARRAY - this array was REINDEXED having another KEY to the same ARRAY LEVEL ... 

I tried ARRAY_MERGE and stuffs like that - but i need could insert in the KEY index I wanted...
(*) The values above are only FOR ILUSTRATION PURPOSE.

I hope someone could help me !!!

Thank u very much for your attention.

Poeta_eletrico

Re: A Real Good Solution: MULTIDIMENSIONAL ARRAY

Posted: Thu Jun 15, 2006 3:11 pm
by Christopher

Code: Select all

$var = array (
     0 => array (
            0 => array (
                    'model 1' => array (
                         '2006-01' => 31.8,
                         ),
                    ),
            1 => array (
                    'model 2' => array (
                         '2006-01' => 31.8,
                         ),
                    ),
            ),
     );

Re: A Real Good Solution: MULTIDIMENSIONAL ARRAY

Posted: Fri Jun 16, 2006 8:23 am
by poeta_eletrico
arborint wrote:

Code: Select all

$var = array (
     0 => array (
            0 => array (
                    'model 1' => array (
                         '2006-01' => 31.8,
                         ),
                    ),
            1 => array (
                    'model 2' => array (
                         '2006-01' => 31.8,
                         ),
                    ),
            ),
     );

Hi Christopher,


Well I really dont know what u tried to tell me with that...can u explain?

Poeta_Eletrico