note 116144 added to control-structures.foreach

From: Date: Fri, 14 Nov 2014 01:55:32 +0000
Subject: note 116144 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-200905@lists.php.net to get a copy of this message
A suggestion was made to use the alternate form <?php foreach($array as $element): #do something endforeach; ?> In my mind this is counter-intuitive, and I have seen it only once. I would suggest using the standard form with curly braces: <?php foreach($array as $element) { // do something } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 50.65.136.251 ---- Manual Page -- http://php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/116144 Del: integrated -- https://master.php.net/note/delete/116144/integrated Del: useless -- https://master.php.net/note/delete/116144/useless Del: bad code -- https://master.php.net/note/delete/116144/bad+code Del: spam -- https://master.php.net/note/delete/116144/spam Del: non-english -- https://master.php.net/note/delete/116144/non-english Del: in docs -- https://master.php.net/note/delete/116144/in+docs Del: other reasons-- https://master.php.net/note/delete/116144 Reject -- https://master.php.net/note/reject/116144 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200905) next »