Edit report at https://bugs.php.net/bug.php?id=63049&edit=1
ID: 63049
Comment by: stanislav at nechutny dot net
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:
TO: franssen dot roland
In your code is error. On line 5 it should be "foreach($it as $key => $value) {"
Previous Comments:
[2012-12-21 13:23:38] franssen dot roland at gmail dot com
I currently have this... which also isn't restricted to just
\RecursiveIterator(s) but uses a more generic approach.
$value) {
if($value instanceof \Traversable) {
$result[$key] = recursive_iterator_to_array($value);
} else {
$result[$key] = $value;
}
}
return $result;
}
[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