note 119284 added to control-structures.foreach
| From: | till at etill dot net | Date: | Tue, 03 May 2016 21:39:29 +0000 |
| Subject: | note 119284 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205420@lists.php.net to get a copy of this message | ||
Note: Empty arrays are handled just fine by foreach, but for fail-safe code, you should always check
that what is passed in fact is an array, like this:
<?php
if( is_array( $a) ) {
foreach( $a as $v) { ... }
} else
// $a is not an array
;
----
Server IP: 93.124.244.58
Probable Submitter: 84.214.189.69
----
Manual Page -- http://php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/119284
Del: integrated -- https://master.php.net/note/delete/119284/integrated
Del: useless -- https://master.php.net/note/delete/119284/useless
Del: bad code -- https://master.php.net/note/delete/119284/bad+code
Del: spam -- https://master.php.net/note/delete/119284/spam
Del: non-english -- https://master.php.net/note/delete/119284/non-english
Del: in docs -- https://master.php.net/note/delete/119284/in+docs
Del: other reasons-- https://master.php.net/note/delete/119284
Reject -- https://master.php.net/note/reject/119284
Search -- https://master.php.net/manage/user-notes.php