Moriyoshi Koizumi wrote:
I tried to answer this question in the bug report page.
[...]
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.
Yes, I understand this. What I don't understand is WHY is it so? Why is foreach handling references specially? Why is your point 2) there?

I probably don't see all the consequences (I know little about PHP/Zend internals and have found no documentation), but wouldn't the fix be as simple as changing the SEPARATE_ZVAL_IF_NOT_REF into SEPARATE_ZVAL on line 2251 of Zend/zend_execute.c? URL: http://lxr.php.net/source/php4/Zend/zend_execute.c#2251 (search for "case ZEND_FE_RESET:" if line numbers shift).

BTW, what's the relation of http://lxr.php.net/source/php4/Zend/ and http://lxr.php.net/source/Zend/ ?

Vaclav Dvorak <[EMAIL PROTECTED]>


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

Reply via email to