PHP 4.0 Bug #3504: unset+reset+each produce false warning
| From: | stas at zend dot com | Date: | Wed, 16 Feb 2000 16:19:34 +0000 |
| Subject: | PHP 4.0 Bug #3504: unset+reset+each produce false warning | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-15589@lists.php.net to get a copy of this message | ||
From: stas@zend.com
Operating system: Linux
PHP version: 4.0 Latest CVS (16/02/2000)
PHP Bug Type: Scripting Engine problem
Bug description: unset+reset+each produce false warning
Code:
<?
$cfgServers[1]['host'] = 'localhost';
$cfgServers[2]['host'] = '';
$cfgServers[3]['host'] = '';
unset($cfgServers[0]);
var_dump($cfgServers);
reset($cfgServers);
while (list($key, $val) = each($cfgServers))
{
print "$key => $val<hr>";
}
?>
Gives warning:
Warning: Variable passed to each() is not an array or object in script.php on line 13
The values are printed OK, but the warning is false - value passed to each *is* an array, and
var_dump reports it and each knows it too, because it iterates over the array OK.