#46093 [Opn->Bgs]: array pointer is different from other versions

From: Date: Wed, 08 Oct 2008 18:13:19 +0000
Subject: #46093 [Opn->Bgs]: array pointer is different from other versions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129563@lists.php.net to get a copy of this message
 ID:               46093
 Updated by:       jani@php.net
 Reported By:      home at oxwiz dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: CentOS release 4.6 (Final)
 PHP Version:      5.2.6
 New Comment:

Pre 5.2.6 result is the unexpected one.


Previous Comments:
------------------------------------------------------------------------

[2008-09-16 11:46:04] home at oxwiz dot com

Description:
------------
I know that the array pointer doing...
if passing arrays to functions, the pointer of the argument(within the
function) is set to First.
and after the foreach, the pointer is set to First; 

But, some version of PHP (like 5.2.6 and 5.2.7-dev) array pointer is
different from other version.
Also, I ever seen it within one of early version of 5.2.6.

test result... 
expected result: 5.0.4(FC 4) , 5.1.6(centos 5)  
actual result:   5.2.6(centos 4.6) , 5.2.7-dev(centos 4.6)

Reproduce code:
---------------
<?
echo "PHP VER. ".phpversion()."<br><br>";
$a =
array('aa'=>'aa','bb'=>'bb','cc'=>'cc');
$aa = array('a'=>$a,'b'=>$a,'c'=>$a);
function testLoop($datas) {
    while (is_array($datas) && list($dk,$data) = each($datas)){
        echo $dk ."<br>";
    }
}

//next ($aa);
foreach ($aa as $ak=>$av) unset ($aa[$ak]['bb']);
list($k,$v) = each($aa);
echo "$k , $v <br>";
echo "testLoop : unexpected result<br>";
testLoop($aa);
echo "<br>rest & testLoop : expected result<br>";
reset($aa);
testLoop($aa);
?>

Expected result:
----------------
PHP VER. 5.0.4

a , Array 
testLoop : unexpected result
a
b
c

rest & testLoop : expected result
a
b
c


Actual result:
--------------
PHP VER. 5.2.6

b , Array 
testLoop : unexpected result
c

rest & testLoop : expected result
a
b
c



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46093&edit=1



Thread (2 messages)

« previous php.bugs (#129563) next »