note 104175 rejected from control-structures.foreach by thiago

From: Date: Tue, 31 May 2011 03:48:20 +0000
Subject: note 104175 rejected from control-structures.foreach by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180108@lists.php.net to get a copy of this message
Note Submitter: lyricnz at gmail dot com ---- There's a gotcha with this. If you are iterating across an array of objects (not arrays), you will be modifying the actual object! $things = array(new stdClass(), new stdClass()); foreach ($things as $thing) { $thing->magic = TRUE; } print_r($things); This will output an array of objects, each with magic=TRUE!

« previous php.notes (#180108) next »