note 109454 added to control-structures.foreach

From: Date: Wed, 18 Jul 2012 16:58:06 +0000
Subject: note 109454 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-189288@lists.php.net to get a copy of this message
This is because arrays are always references. When you get the value in a foreach and that value is an array, you actually get a copy of the REFERENCE to the array. So when you modify a nested array using foreach you are actually modifying the nested array. ---- Server IP: 69.147.83.197 Probable Submitter: 199.58.199.98 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/109454 Del: integrated -- https://master.php.net/note/delete/109454/integrated Del: useless -- https://master.php.net/note/delete/109454/useless Del: bad code -- https://master.php.net/note/delete/109454/bad+code Del: spam -- https://master.php.net/note/delete/109454/spam Del: non-english -- https://master.php.net/note/delete/109454/non-english Del: in docs -- https://master.php.net/note/delete/109454/in+docs Del: other reasons-- https://master.php.net/note/delete/109454 Reject -- https://master.php.net/note/reject/109454 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189288) next »