RE: [PHP] Infinite loop with for(), sizeof()

From: Date: Mon, 24 Jul 2000 18:59:01 +0000
Subject: RE: [PHP] Infinite loop with for(), sizeof()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7833@lists.php.net to get a copy of this message
use each() for arrays (best used with list()) while(list($key, $val) = each($names)): { echo "<BR>".trim($names[$key]); } -----Original Message----- From: Steve Chadsey [mailto:schadsey@anathema.lightbridge.com] Sent: Monday, July 24, 2000 12:08 AM To: php-general@lists.php.net Subject: [PHP] Infinite loop with for(), sizeof() Hello, I'm wondering what I'm doing wrong here, with the following code: ---[start]----- <? $names[0] = "Hello World "; for($i = 0;$i <= sizeof($names); $i++) { print $i . "<br>\n"; $names[$i] = trim($names[$i]); } ?> ---[end]----- It runs until I stop it. It does this with PHP/4.0.1pl2 on both a Solaris 2.6 box and a Linux 2.2.14 box, both with apache 1.3.12. If no one else can reproduce this, then I'll feel really bad. -- Steve Chadsey <schadsey@anathema.lightbridge.com> Now playing: Time Is Coming (Testament - "Practice What You Preach") -- 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 (#7833) next »