note 29922 deleted from control-structures.foreach by sniper
| From: | sniper@php.net | Date: | Tue, 10 Jun 2003 22:51:33 +0000 |
| Subject: | note 29922 deleted from control-structures.foreach by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50136@lists.php.net to get a copy of this message | ||
Note Submitter: julian@hungrystarfish.co.uk
----
Just a simple point, but it caused me a bit of head-scratching!
Using foreach on an empty array causes some sort of error which made my apache server fall over.
Check the array first using 'empty' just to be sure!
if (!empty($array))
{
foreach ($array as $key => $value)
{
....
}
}