note 29922 added to control-structures.foreach

From: Date: Fri, 28 Feb 2003 20:10:11 +0000
Subject: note 29922 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-44673@lists.php.net to get a copy of this message
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) { .... } } -- http://www.php.net/manual/en/control-structures.foreach.php http://master.php.net/manage/user-notes.php?action=edit+29922 http://master.php.net/manage/user-notes.php?action=delete+29922 http://master.php.net/manage/user-notes.php?action=reject+29922

« previous php.notes (#44673) next »