Re: Iterators
| From: | Jochem Maas | Date: | Mon, 12 Feb 2007 19:33:08 +0000 |
| Subject: | Re: Iterators | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248783@lists.php.net to get a copy of this message | ||
Marc Weber wrote:
>
> <?php
>
> function A()
> {
> return new RecursiveArrayIterator(array(func_get_args()));
> }
> $a=iterator_to_array(new RecursiveIteratorIterator( A (A(2) , A (3,4),
> A(5,6))));
> var_dump($a);
>
> ?>
>
> I'd expect this to output an array containing 2,3,4,5,6.
> But the result is:
>
> array(2) {
> [0]=>
> int(5)
> [1]=>
> int(6)
> }
>
> What did I miss here?
how should we know with out seeing the iterator_to_array() definition?
function A() {
$a = func_get_args();
return new RecursiveArrayIterator(array($a));
}
$a = new RecursiveIteratorIterator( A(A(2) , A(3,4), A(5,6)) );
foreach ($a as $b) echo $b;
the above code outputs: 23456 - so the problem looks to be in your
iterator_to_array() function.
>
> Marc
>
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>