Find keys in multidimensional array
| Newsgroups | php.general |
|---|---|
| Message-ID | <CACOt7mFT6ZEMWZWUj8xC0dQDahE+T1S6PEtm68q-r_d609G8cw@mail.gmail.com> |
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.