|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-01 20:55 UTC] tony2001@php.net
[2005-12-01 21:15 UTC] ngaugler at ngworld dot net
[2005-12-01 21:18 UTC] ngaugler at ngworld dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 12:00:01 2025 UTC |
Description: ------------ In 4.4.1, when you unserialize an array, then attempt to globalize it within a function, and then pass it to an internal array function such as next or key, it does not work as it was in 4.3.10 or how it functions in PHP 5.0.5. This functions as expected in 4.3.10 and 5.0.5. The documentation clearly states you are not to use next(&array) or key(&array) when using references, which is why this is not used. Reproduce code: --------------- <? $ar = array(array('ID' => 'BOB'), array('ID' => 'GEORGE'), array('ID' => 'JOHN')); $ser = serialize($ar); $arn = unserialize($ser); print_r($arn) . "\n\n"; function breakPHP() { global $arn; for ($i = 0, reset($arn); ($key = key($arn)), (isset($key)); next($arn), $i++) { print "$key ... " . $arn[$key]['ID'] . "<br>\n"; if ($i > 5) { print "we looped"; exit; } } } breakPHP(); ?> Expected result: ---------------- Array ( [0] => Array ( [ID] => BOB ) [1] => Array ( [ID] => GEORGE ) [2] => Array ( [ID] => JOHN ) ) 0 ... BOB<br> 1 ... GEORGE<br> 2 ... JOHN<br> Actual result: -------------- Array ( [0] => Array ( [ID] => BOB ) [1] => Array ( [ID] => GEORGE ) [2] => Array ( [ID] => JOHN ) ) 0 ... BOB<br> 0 ... BOB<br> 0 ... BOB<br> 0 ... BOB<br> 0 ... BOB<br> 0 ... BOB<br> 0 ... BOB<br>