note 102978 added to control-structures.foreach

From: Date: Thu, 17 Mar 2011 21:04:35 +0000
Subject: note 102978 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-177968@lists.php.net to get a copy of this message
@benekastah You are unintentionality misleading people. Your code is the same as this: <?php $array = array('a', 'b', 'c', 'd'); foreach ( $array as $letter ) ; echo $letter; ?> What I mean by this is that you execute the foreach loop but don't do anything with it. The reason you can echo the last value in the array is because of the warning posted above: "Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset()." ---- Server IP: 69.147.83.197 Probable Submitter: 128.187.97.4 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/102978 Del: integrated -- https://master.php.net/note/delete/102978/integrated Del: useless -- https://master.php.net/note/delete/102978/useless Del: bad code -- https://master.php.net/note/delete/102978/bad+code Del: spam -- https://master.php.net/note/delete/102978/spam Del: non-english -- https://master.php.net/note/delete/102978/non-english Del: in docs -- https://master.php.net/note/delete/102978/in+docs Del: other reasons-- https://master.php.net/note/delete/102978 Reject -- https://master.php.net/note/reject/102978 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177968) next »