note 30983 added to control-structures.while

From: Date: Sat, 05 Apr 2003 10:46:15 +0000
Subject: note 30983 added to control-structures.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-46250@lists.php.net to get a copy of this message
When you do a while loop like this: $String=array ("a","b","c"); $i=0; while ($String[$i]) { echo $String[$i]; $i++; } And error reporting is set to E_ALL you get a warning message saying there's an undefined index. There's a simple solution to this: $String=array ("a","b","c); $i=0; while ($i<count($String) { echo $String[$i]; $i++; } And away the warning is! -- http://www.php.net/manual/en/control-structures.while.php http://master.php.net/manage/user-notes.php?action=edit+30983 http://master.php.net/manage/user-notes.php?action=delete+30983 http://master.php.net/manage/user-notes.php?action=reject+30983

« previous php.notes (#46250) next »