#46093 [NEW]: array pointer is different from other versions

From: Date: Tue, 16 Sep 2008 11:46:04 +0000
Subject: #46093 [NEW]: array pointer is different from other versions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129017@lists.php.net to get a copy of this message
From:             home at oxwiz dot com
Operating system: CentOS release 4.6 (Final)
PHP version:      5.2.6
PHP Bug Type:     Arrays related
Bug description:  array pointer is different from other versions

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 bug report at http://bugs.php.net/?id=46093&edit=1
-- 
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46093&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46093&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46093&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46093&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=46093&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46093&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46093&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46093&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46093&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46093&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=46093&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=46093&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46093&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46093&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46093&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46093&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46093&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46093&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46093&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46093&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#129017) next »