A Real Good Solution: MULTIDIMENSIONAL ARRAY

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
poeta_eletrico
Forum Commoner
Posts: 32
Joined: Mon Dec 22, 2003 7:33 am
Contact:

A Real Good Solution: MULTIDIMENSIONAL ARRAY

Post 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
Last edited by poeta_eletrico on Fri Jun 16, 2006 8:24 am, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: A Real Good Solution: MULTIDIMENSIONAL ARRAY

Post 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,
                         ),
                    ),
            ),
     );
(#10850)
poeta_eletrico
Forum Commoner
Posts: 32
Joined: Mon Dec 22, 2003 7:33 am
Contact:

Re: A Real Good Solution: MULTIDIMENSIONAL ARRAY

Post 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
Post Reply