I think this is what you want $ritit = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); $result = array(); foreach ($ritit as $leafValue) { $path = 'foo99'; foreach (range(0, $ritit->getDepth()) as $depth) { $path . = sprintf('%s', $ritit->getSubIterator($depth)->key()); } $result$path = $leafValue; } By default, RecursiveIteratorIterator only visits leaf nodes, so each iteration of the outer foreach loop has the iterator structure stopped on one of the values you care about. We find the keys that build our path to where we are by taking a peek at the iterators that RecursiveIteratorIterator is creating and managing for us(one iterator is used for each level).
Awesome, thanks chris! I should really learn more about the SPL – deadkarma Apr 24 '10 at 7:04.
1 First sentence of the question: "Say I have a form with these fields, and cannot rename them..." – Frank Farmer Apr 23 '10 at 23:41.
Not the answer to your question but alternatively there is extract which will take an array and produce variables from them. Eg; $array = array ( foo => foo bar boo => something else ) extract($array); Output $foo = 'foo bar'; $boo = 'something else'; There are a few options on how to handle identically index names for example, over write existing value or append a prefix to the variable name.
2 using extract with user input is always bad idea – Col. Shrapnel Apr 23 '10 at 22:44 a very valid point. Had not considerred this.
– bigstylee Apr 23 '10 at 23:06.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.