Re: PHP 4.0 Bug #8622: Using "0" as a key in accociative arrays crashes reset() , next(), etc.
| From: | Boian Bonev | Date: | Wed, 10 Jan 2001 00:10:55 +0000 |
| Subject: | Re: PHP 4.0 Bug #8622: Using "0" as a key in accociative arrays crashes reset() , next(), etc. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-43620@lists.php.net to get a copy of this message | ||
hi,
the 0 evals to false and stops your for loop, not reset... try the following
loop line instead:
while (list($key,$dummy)=each($groupid)) {
b.
----- Original Message -----
From: <sooprock@aol.com>
To: <php-dev@lists.php.net>
Sent: Wednesday, January 10, 2001 2:05 AM
Subject: [PHP-DEV] PHP 4.0 Bug #8622: Using "0" as a key in accociative
arrays crashes reset() , next(), etc.
> From: sooprock@aol.com
> Operating system: Linux (also NT)
> PHP version: 4.0.4
> PHP Bug Type: Scripting Engine problem
> Bug description: Using "0" as a key in accociative arrays crashes reset()
, next(), etc.
>
> <?
> print "Using \"0\" as a key in accociative arrays<br>\n"
> ."crashes reset() , next(), etc.<br><br>\n\n";
>
> $groupid["SHOOT"] = "DARNIT";
> $groupid["DER"] = "DARNIT";
> $groupid["FSD"] = "DARNIT";
> $groupid["SDF"] = "DARNIT";
> $groupid["DSF"] = "DARNIT";
> $groupid["0"] = "DARNIT";
> $groupid["DSF2"] = "DARNIT";
>
> print "REGULAR VARIABLE REFERENCING WORKS:<br>\n";
> print "\$groupid[\"SHOOT\"] =
> ".$groupid["SHOOT"]."<br>\n";
> print "\$groupid[\"DER\"] =
> ".$groupid["DER"]."<br>\n";
> print "\$groupid[\"FSD\"] =
> ".$groupid["FSD"]."<br>\n";
> print "\$groupid[\"0\"] =
> ".$groupid["0"]."<br>\n";
> print "\$groupid[\"SDF\"] =
> ".$groupid["SDF"]."<br>\n";
> print "\$groupid[\"DSF\"] =
> ".$groupid["DSF"]."<br>\n";
> print "\$groupid[\"DSF2\"] = "
> .$groupid["DSF2"]."<br><br>\n";
>
> print "arraycount = ".count($groupid)."<BR>\n";
> print "Using 'for (reset(\$groupid); \$key = key(\$groupid);
next(\$groupid))'<BR>\n";
> for (reset($groupid); $key = key($groupid); next($groupid)) {
> print "\$groupid[\"$key\"] = $groupid[$key]<br>\n";
> }
> print "<br>\nThe arraycount still works and so does<br>\n"
> ."referencing the variable, however, the reset()<br>\n"
> ."next(), and associated functions crash.<br>\n";
> ?>
>
>
> --
> Edit Bug report at: http://bugs.php.net/?id=8622&edit=1
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>