|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-01-09 19:05 UTC] sooprock at aol dot com
<?
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";
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
IIRC this is described in the manual. use while( list( $key , ) = each( $groupid ) ) { ... }