Edit report at https://bugs.php.net/bug.php?id=63049&edit=1
ID: 63049 Comment by: franssen dot roland at gmail dot com Reported by: franssen dot roland at gmail dot com Summary: iterator_to_array for recursive iterators Status: Open Type: Feature/Change Request Package: SPL related Operating System: Ubuntu PHP Version: 5.4.6 Block user comment: N Private report: N New Comment: I currently have this... which also isn't restricted to just \RecursiveIterator(s) but uses a more generic approach. <?php function recursive_iterator_to_array(\Traversable $it) { $result = array(); foreach($result as $key => $value) { if($value instanceof \Traversable) { $result[$key] = recursive_iterator_to_array($value); } else { $result[$key] = $value; } } return $result; } Previous Comments: ------------------------------------------------------------------------ [2012-12-21 10:35:43] datib...@php.net Ignore my previous comment. That would flatten the array instead. My apologies. ------------------------------------------------------------------------ [2012-12-21 10:29:57] datib...@php.net Why not just do this instead? iterator_to_array(new RecursiveIteratorIterator($it)); ------------------------------------------------------------------------ [2012-09-09 12:14:49] franssen dot roland at gmail dot com Description: ------------ It would be nice to have a recursive_iterator_to_array function to transform a \RecursiveIterator to a full recursive array... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63049&edit=1