note 41147 added to control-structures.foreach

From: Date: Wed, 31 Mar 2004 18:32:32 +0000
Subject: note 41147 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-67427@lists.php.net to get a copy of this message
Here's a note, something mildly annoying: If you use foreach() on an array that happens to be empty, you will get an error, so in cases where you're building an array dynamically and the array might be empty, you have to test for sizeof($array) > 0 before doing a foreach(). It would be nice if foreach() just skipped itself for empty arrays, but it's not hard to test ... just more typing. :) ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41147 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41147&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41147&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67427) next »