PHP 4.0 Bug #4453: Array of widgets problem when array is zero based

From: Date: Mon, 15 May 2000 15:44:54 +0000
Subject: PHP 4.0 Bug #4453: Array of widgets problem when array is zero based
Groups: php.dev 
Request: Send a blank email to php-dev+get-18769@lists.php.net to get a copy of this message
From: redbadge@mindspring.com Operating system: Linux RedHat 6.1 (2.2.12-20) PHP version: 4.0 Release Candidate 2 PHP Bug Type: Other Bug description: Array of widgets problem when array is zero based I have recreated this problem in both PHP 3.0.16 and 4.0 RC2. When using an array of checkboxes that had a zero based value, the following script had variable and erratic results. When the commented out for{} construct that start at 1 are added back and comment out the for{} that uses 0, it works fine. After reviewing the Open Bug Report list, I have found that Bug ID #4433 may be having the same problem. Script to recreate problem: ---------------------------- <?php echo "<form action='$PHP_SELF' method='post'>\n"; $NumChecks = count($chkArray); echo "The number of Checks in the array is: $NumChecks<BR>\n"; if ($NumChecks > 0) { for ($y=0; $y<$NumChecks; ++$y) //for ($y=1; $y<=10; ++$y) { echo "\$chkArray[$y] is $chkArray[$y]<BR>\n"; } } else { echo "\$chkArray is empty<BR>\n"; } $NumHide = count($HideArray); echo "The number of Hidden items in the array is: $NumHide<BR>\n"; If ($NumHide > 0) { for ($y=0; $y<$NumHide; ++$y) //for ($y=1; $y<=$NumHide; ++$y) { echo "\$HideArray[$y] is $HideArray[$y] <br>\n"; } } else { echo "\$HideArray is empty<BR>\n"; } //for( $x=1; $x<=10; ++$x) for( $x=0; $x<10; ++$x) { $strChecked = ""; if ( $chkArray[$x] == $x ) { $strChecked = " checked "; } $HideVal = $x+100; echo "<input type='checkbox' name='chkArray[$x]' value=$x".$strChecked."><br>\n"; echo "<input type='hidden' name='HideArray[$x]' value=$HideVal>\n"; } echo "<input type='submit' name='GetData' value='Submit'>"; echo "</form>"; ?>

« previous php.dev (#18769) next »