Ah, I understand now... This perhaps in a documentation problem then
after all, as there is no way to change this behavior cleanly that I can
see... What about making a copy of the array and all of the references
associated with that array instead of just using the real array?

Just a thought. 

John


>What I meant by this is
>
>1) Each time before entering a foreach loop, php first tries 
>to make a copy of
>   the array being iterated.
>
>2) In case the array variable is either referenceing another 
>variable or
>   referenced by another variable, no copy is made here and 
>the original
>   array is used instead. Because of this behaviour, the 
>original's internal
>   array pointer increases in the loop eventually.
>
>And once a variable is referenced by another, both are treated 
>as "reference" from then on. For example,
>
><?php
>  $test = array();
>  $test['a'] = 'a';
>  $test['b'] = &$test['a'];
>
>  debug_zval_dump($test);
>?>
>
>This script produces following output:
>
>array(2) refcount(2){
>  ["a"]=>
>  &string(1) "a" refcount(2)
>  ["b"]=>
>  &string(1) "a" refcount(2)
>}
>
>Moriyoshi
>
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to