note 30983 deleted from control-structures.while by felipe
| From: | felipe@php.net | Date: | Tue, 29 Jan 2008 11:19:20 +0000 |
| Subject: | note 30983 deleted from control-structures.while by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135509@lists.php.net to get a copy of this message | ||
Note Submitter: tcn at pandora dot be
----
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!