I'm trying to create a data structure consisting of nested associative arrays.
It is created by:
Taking an array from a query result using mysql_fetch_array($result, MYSQL_ASSOC).
Then iterate through this array. Each attribute name in this array is compared to a lookup table which will determine whether the attribute value references another table, i.e. the value is a code that is the primary key of another table.
For every attribute value that is a code that has a table to reference, fetch the data and replace the original string value (in the first array) with this new array.
And so on.
There could be anything from 0 to 5 levels to fetch referenced tuple data for, so I've been trying to come up with a recursive function to do this, but have failed so far.
Does anybody have any tips for iterating through such a simple structure, and applying a function to each member like the above; or maybe a link to an article that has a strategy?
I am of course not looking for code from you, I'm probably just missing some convenient PHP construct for doing this.