|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-09-09 12:14 UTC] 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... PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
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; }TO: franssen dot roland In your code is error. On line 5 it should be "foreach($it as $key => $value) {"