while question

From: Date: Mon, 17 Nov 2008 13:01:19 +0000
Subject: while question
Groups: php.general 
Request: Send a blank email to php-general+get-283345@lists.php.net to get a copy of this message
Hi, i'm on PHP training and our lector is telling us that to avoid counting an array item amout thanks count($my_array), he tells we can do: while($my_array) { ... do something } but from experience this is an infinity loop... it should be always something like $count = count($my_array); while($i <= $count) { ... do something ... $i++; } has someone already use such syntax ? i mean as the first one. thx. -- Alain ------------------------------------ Windows XP SP3 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008

« previous php.general (#283345) next »