note 106971 added to control-structures.foreach

From: Date: Thu, 22 Dec 2011 09:11:51 +0000
Subject: note 106971 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-185201@lists.php.net to get a copy of this message
<?php $d3 = array('a'=>array('b'=>'c')); foreach($d3['a'] as &$v4){} foreach($d3 as $v4){} var_dump($d3); ?> will get something look like this: array(1) { ["a"]=> array(1) { ["b"]=> &array(1) { ["b"]=> *RECURSION* } } } then you try to walk some data with this array. the script run out of memory and connect reset by peer the document says: Warning Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). so what I learn is that NEVER ignore """Warning""" in document.... ---- Server IP: 208.69.120.55 Probable Submitter: 125.71.228.149 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/106971 Del: integrated -- https://master.php.net/note/delete/106971/integrated Del: useless -- https://master.php.net/note/delete/106971/useless Del: bad code -- https://master.php.net/note/delete/106971/bad+code Del: spam -- https://master.php.net/note/delete/106971/spam Del: non-english -- https://master.php.net/note/delete/106971/non-english Del: in docs -- https://master.php.net/note/delete/106971/in+docs Del: other reasons-- https://master.php.net/note/delete/106971 Reject -- https://master.php.net/note/reject/106971 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185201) next »