OK, here's the challenge I'm facing and it is quite a complicated one :
- I'm having a multi-dimensional array (it can be just an array or it can go several levels deep)
- I have a set of "allowed" keys (containing "parent.child" keys as well)
- In the final array, we only need numeric keys and allowed keys. All the rest has to be dropped from the final table.
Example initial array :
Array
(
[0] => Array
(
[Title] => La science des rêves
[Year] => 2006
[Director] => Array
(
[Name] => Michel Gondry
[BirthYear] => 1963
[BirthPlace] => Versailles, Yvelines, France
)
)
[1] => Array
(
[Title] => Arizona Dream
[Year] => 1992
[Director] => Array
(
[Name] => Emir Kusturica
[BirthYear] => 1954
[BirthPlace] => Sarajevo, Bosnia and Herzegovina, Yugoslavia
)
)
)
Example allowed keys :
Array
(
[0] => Title
[1] => Director.Name
[2] => Director.BirthYear
)
I want to filter it so that the final array contains just the above keys (the numeric keys will be kept no-matter-what) :
Array
(
[0] => Array
(
[Title] => La science des rêves
[Director.Name] => Michel Gondry
[Director.BirthYear] => 1963
)
[1] => Array
(
[Title] => Arizona Dream
[Director.Name] => Emir Kusturica
[Director.BirthYear] => 1954
)
)
Any ideas on how to do this? I've been struggling for hours, with all sorts of recursive functions but I'm always seemingly missing something... :S