I've got a multidimensional array of which I can't know the depth. The array could for example look like this:
$array = array(
1 => array(
5 => array(
3 => 'testvalue1'
)
),
2 => array(
6 => 'testvalue2'
),
3 => 'testvalue3',
4 => 'testvalue4',
);
With this array I want to create a table of contents. That means the keys need to be preserved as I'm using them as "chapter numbers". For example, "testvalue1" is in chapter 1.5.3.
Now I want to walk through the array while preserving all keys - not using array_walk_recursive as the keys containing another array are dropped (correct?) and preferably not using nested foreach loops considering the speed.
Any suggestions how I should do this? Thanks in advance.
PS: For my script it doesn't matter if the keys are strings ("1" instead of 1) or integers, if having strings as key will make array_walk_recursive preserve them.