Re: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-22 Thread Vaclav Dvorak
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

Re: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-22 Thread Moriyoshi Koizumi
On Wed, Jan 22, 2003 at 04:12:18PM +0100, Vaclav Dvorak wrote: 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

Re: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-22 Thread Vaclav Dvorak
Moriyoshi Koizumi wrote: Moriyoshi Koizumi wrote: 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

RE: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-21 Thread John Coggeshall
To answer part of your question: One more thing: whether this bug is fixed or not, the documentation must be clarified! I don't know about you, but I simply don't understand what it's supposed to say. Quoting: Note: Also note that foreach operates What the documentation means is that

Re: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-21 Thread Moriyoshi Koizumi
Hi, ?php $a = array(1,2,3); #$r = $a; echo current before foreach: . current($a) . br\n; foreach($a as $b) { echo - value in cycle: . $b . br\n; echo -- current in cycle: . current($a) . br\n; } echo current before foreach: . current($a) . br\n; ? Try it, and the delete

RE: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-21 Thread John Coggeshall
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.

Re: [PHP-DEV] foreach nastiness with references (bug #21702)

2003-01-21 Thread Moriyoshi Koizumi
Just FYI, here's a relevant commit made by Andi two years ago: http://cvs.php.net/diff.php/Zend/zend_execute.c?r1=1.222r2=1.223ty=h Moriyoshi John Coggeshall [EMAIL PROTECTED] wrote: Ah, I understand now... This perhaps in a documentation problem then after all, as there is no way to change