|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-04-14 01:15 UTC] jc at mega-bucks dot co dot jp
The following piece of code never terminates:
<?php
while (list($k, $v) = each( $_POST )) {
if(strstr($k, "CHANGE_DEL_DATES")) {
session_set_post_vars( $_POST );
}
}
function session_set_post_vars($post) {
$_SESSION["S_POST_VALUES"] = $post;
}
?>
The contents of the $_POST superglobal were:
Array
(
[CURRENT_DEL_METHOD] => YAMATO
[DEL_YEAR1] => 2003
[DEL_MONTH1] => 04
[DEL_DAY1] => 12
[ptime1] => 1
[DEL_YEAR2] => 2003
[DEL_MONTH2] => 04
[DEL_DAY2] => 12
[DEL_YEAR3] => 2003
[DEL_MONTH3] => 04
[DEL_DAY3] => 12
[DELIVER_ANYDAY] => on
[CHANGE_DEL_DATES_x] => 14
[CHANGE_DEL_DATES_y] => 7
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
Here is a shorter example that demonstrates the problem: <?php $arr = array('a', 'b'); while (each($arr)) $arr2 = $arr; ?>This makes no sense to me, why would assigning an array to another variable affect the original arrays pointer? Even the array it's assigned to keeps the original pointer: <?php $array = array('a','b','c'); print "1: " . current($array) . "\n"; // a print "2: " . next($array) . "\n"; // b $array2 = $array; print "3: " . current($array) . "\n"; // a print "4: " . current($array2). "\n"; // b ?> Either $array should also keep its pointer or $array2 should also have a reset pointer. I'd assume both would keep the current pointer, or maybe just $array2 would have a reset pointer :). Current behavior is certainly not documented, and are you guys sure this isn't a bug?