ID: 16227
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Arrays related
Operating System: Tru64 UNIX 5.0a
PHP Version: 4.0.6
Assigned To: hholzgra
New Comment:
BTW, I haven't check the exact behavior.
Zend might be resetting internal hash position due to the
assignment.
Previous Comments:
------------------------------------------------------------------------
[2002-03-22 20:48:18] [EMAIL PROTECTED]
I forgot about reset() since behavior is inconsistent :(
Anyway, this is still not right.
Zend engine is allocating new zval for $insidearray while
it should allocate $placeholder.
---
$placeholder = $insidearray;
while(list(,$innerval) = each($insidearray)){
print "inloop $innerval for $outerval<br>";
---
This bug causes nasty bug in script.
If it is not easy to fix, may be we should suspend this bug?
------------------------------------------------------------------------
[2002-03-22 20:29:04] [EMAIL PROTECTED]
ever heard of reset() ?
------------------------------------------------------------------------
[2002-03-22 20:19:56] [EMAIL PROTECTED]
Thanks for reporting. I verified with 4.2.0-dev & 4.0.6.
This is _VERY_ bad bug...
[root@dev etc]# php
<?php
$outsidearray = array("key1","key2");
$insidearray = array("0","1");
while(list(,$outerval) = each($outsidearray)){
//$placeholder = $insidearray;
while(list(,$innerval) = each($insidearray)){
print "inloop $innerval for $outerval<br>";
}
}
?>
inloop 0 for key1<br>
inloop 1 for key1<br>
[root@dev etc]# php
<?php
$outsidearray = array("key1","key2");
$insidearray = array("0","1");
while(list(,$outerval) = each($outsidearray)){
$placeholder = $insidearray;
while(list(,$innerval) = each($insidearray)){
print "inloop $innerval for $outerval<br>";
}
}
?>
inloop 0 for key1<br>
inloop 1 for key1<br>
inloop 0 for key2<br>
inloop 1 for key2<br>
[root@dev etc]#
[root@dev etc]# php -v
4.2.0-dev
------------------------------------------------------------------------
[2002-03-22 19:52:31] [EMAIL PROTECTED]
nested while(list=each) produces weird results.
this code
<?php
$outsidearray = array("key1","key2");
$insidearray = array("0","1");
while(list(,$outerval) = each($outsidearray)){
//$placeholder = $insidearray;
while(list(,$innerval) = each($insidearray)){
print "inloop $innerval for $outerval<br>";
}
}
?>
only gets to key1 of the outer loop.
But if you uncomment the $placeholder line,
it works ok.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16227&edit=1