ID: 35019
Updated by: [EMAIL PROTECTED]
Reported By: pee at erkkila dot org
-Status: Open
+Status: Assigned
Bug Type: Arrays related
Operating System: linux
PHP Version: 5.1.0RC4
-Assigned To:
+Assigned To: iliaa
Previous Comments:
------------------------------------------------------------------------
[2005-10-30 00:18:46] pee at erkkila dot org
Description:
------------
Found a difference in mediawiki 1.5 with php4 vs php5. After tracking
it down it looks like key() might be returning incorrect information
inside a for loop. I might be missing a scope change someplace too
though. This test case is based on Parser.php from that package.
Reproduce code:
---------------
<?php
function one(&$state) {
$state = array (
'oneKey' => "oneValue",
'twoKey' => "twoValue",
'threeKey' => "threeValue",
'fourKey' => "fourValue",
);
}
function two(&$state) {
for ( $contentDict = end( $state ); $contentDict !== false;
$contentDict = prev( $state ) ) {
print("Key:" . key($state) . "\n");
print("Value:" . $contentDict . "\n");
}
}
one($state);
two($state);
?>
Expected result:
----------------
Key:fourKey
Value:fourValue
Key:threeKey
Value:threeValue
Key:twoKey
Value:twoValue
Key:oneKey
Value:oneValue
Actual result:
--------------
Key:oneKey
Value:fourValue
Key:oneKey
Value:threeValue
Key:oneKey
Value:twoValue
Key:oneKey
Value:oneValue
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35019&edit=1