Re: Iterators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux