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

From: Date: Sat, 26 Aug 2000 01:03:54 +0000
Subject: Re: each() bug? Can you try this to verify?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13765@lists.php.net to get a copy of this message
if you are going to loop throught the array again, you need to reset the array pointer like so: reset($array); Then you can loop through it again with each() -jeremy brand _______________________________________________________________________ GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9 _ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more __ On Fri, 25 Aug 2000, Hans H. Anderson wrote: > Date: Fri, 25 Aug 2000 17:56:39 -0600 (MDT) > From: Hans H. Anderson <hans@hansanderson.com> > To: php-general@lists.php.net > Subject: [PHP] each() bug? Can you try this to verify? > > 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. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#13765) next »