note 87532 added to language.references

From: Date: Tue, 09 Dec 2008 13:09:19 +0000
Subject: note 87532 added to language.references
Groups: php.notes 
Request: Send a blank email to php-notes+get-147948@lists.php.net to get a copy of this message
A little gotcha (be careful with references!): <?php $arr = array('a'=>'first', 'b'=>'second', 'c'=>'third'); foreach ($arr as &$a); // do nothing. maybe? foreach ($arr as $a); // do nothing. maybe? print_r($arr); ?> Output: Array ( [a] => first [b] => second [c] => second ) Add 'unset($a)' between the foreachs to obtain the 'correct' output: Array ( [a] => first [b] => second [c] => third ) ---- Server IP: 190.54.16.132 Probable Submitter: 200.111.44.196 ---- Manual Page -- http://www.php.net/manual/en/language.references.php Edit -- https://master.php.net/note/edit/87532 Del: integrated -- https://master.php.net/note/delete/87532/integrated Del: useless -- https://master.php.net/note/delete/87532/useless Del: bad code -- https://master.php.net/note/delete/87532/bad+code Del: spam -- https://master.php.net/note/delete/87532/spam Del: non-english -- https://master.php.net/note/delete/87532/non-english Del: in docs -- https://master.php.net/note/delete/87532/in+docs Del: other reasons-- https://master.php.net/note/delete/87532 Reject -- https://master.php.net/note/reject/87532 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147948) next »