each() bug? Can you try this to verify?

From: Date: Fri, 25 Aug 2000 23:56:39 +0000
Subject: each() bug? Can you try this to verify?
Groups: php.general 
Request: Send a blank email to php-general+get-13763@lists.php.net to get a copy of this message
Hello, Have php3 and php4 on my local machine in a cgi configuration to do stuff from the command line. I am having a problem in both that looks like it could be some sort of bug. Can others please test the following code and tell me if you see anything on the second loop? I've included two different arrays, please run with both or either, as you wish. Thanks, ------ <?php //$array = array("hans"=>"brent"); $array = array("hans"=>"brent","annie"=>"anne"); print sizeof($array) . "\n"; // loop, output data while(list($k,$v) = each($array)) { print "k=v: $k=$v\n"; } print sizeof($array) . "\n"; // loop again, should output the same data, but doesn't on my machine while(list($k,$v) = each($array)) { print "k=v: $k=$v\n"; } print sizeof($array) . "\n"; print "Where are the values of array on the second loop? GONE! Why?\n"; ?> ------ Hans Anderson ~ me@hansanderson.com PO Box 426, Missoula, MT 59806 | PHP, Search Engines, SQL (800)397-9116 / (406)549-6524 | Databases, Flash Multimedia, http://www.hansanderson.com | Killer Audio Production, http://www.goofiness.com | Minty Fresh Breath.

« previous php.general (#13763) next »