note 30983 modified in control-structures.while by vrana

From: Date: Tue, 17 Aug 2004 13:55:15 +0000
Subject: note 30983 modified in control-structures.while by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79902@lists.php.net to get a copy of this message
When you do a while loop like this: <?php $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: <?php $String=array ("a","b","c); $i=0; while ($i<count($String)) { echo $String[$i]; $i++; } ?> And away the warning is! --was-- 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://php.net/manual/en/control-structures.while.php

« previous php.notes (#79902) next »