PHP 4.0 Bug #4453 Updated: Array of widgets problem when array is zero based
| From: | Bug Database | Date: | Tue, 25 Jul 2000 21:38:52 +0000 |
| Subject: | PHP 4.0 Bug #4453 Updated: Array of widgets problem when array is zero based | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-26107@lists.php.net to get a copy of this message | ||
ID: 4453
Updated by: zak
Reported By: redbadge@mindspring.com
Status: Closed
Bug Type: Other
Assigned To:
Comments:
This is a problem with the logic for the program, not with PHP.
PHP considers "" and 0 to be equivalent when using the == operator. In PHP 4 you can use
the === operator to ensure that the values being compared match in type and in value.
Note that data posted via a form is considered to be a string, so for the equivalency test I place
$x in quotes to cast it to a string.
Change this line:
if ( $chkArray[$x] == $x ) { $strChecked = " checked "; }
to this:
if ($chkArray[$x] === "$x") {$strChecked = " checked";}
and your script should work as anticipated.
Full Bug description available at: http://bugs.php.net/?id=4453