Find keys in multidimensional array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello. I have a multidimensional array.

Some 'routes' only go 2-3 key/values down, While other options have
6-10 keys deep (Ive not planned this as yet - just started)..

In the below array (just random words) I'm 'at' the 'Ginger' option
now. I am wondering if there was a quick way of searching the array
for 'Ginger' and finding the path "up"  the array to get the key 2
levels up.

So for this example i'll want to go 'up' 2 levels to get 'crackers'

(each unique key, will have a TITLE value, and a number of OPTIONS -
2-6 options each)

Is there a quick way of doing this ?

EXAMPLE array:-

(
    [top] => Array
        (
            [CRUSH] => Array
                (
                    [TITLE] => Crush
                    [OPTION1] => Array
                        (
                            [cheese] => Array
                                (
                                    [TITLE] => Cheese option
                                )

                        )

                    [OPTION2] => Array
                        (
                            [crackers] => Array
                                (
                                    [TITLE] => crackers
                                    [OPTION1] => Array
                                        (
                                            [NAME] => crackers option 1
                                            [Ginger] => Array
                                                (
                                                    [TITLE] => Ginger title1
                                                    [TITLE2] => Ginger title2
                                                )

                                        )

                                    [OPTION2] => crackers option 2
                                )

                        )

                )

        )

)





-- 

Gordon.



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux