note 68268 added to control-structures.foreach
| From: | supportatmediaartdotru at osu1 dot php dot net | Date: | Thu, 20 Jul 2006 08:46:24 +0000 |
| Subject: | note 68268 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114963@lists.php.net to get a copy of this message | ||
php at kormoc dot com 11-May-2006 10:25 wrote:
With foreach and references, there is a super easy way to corrupt your data.
But you can avoid it by destruction of the hard link $item
<?php
$array = array(1,2,3);
foreach( $array as &$item );
unset($item);
foreach( $array as $item );
print_r( $array );
?>
----
Server IP: 195.222.164.18
Probable Submitter: 80.80.111.129 (proxied: 80.80.122.8)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/note/edit/68268
Del: integrated -- http://master.php.net/note/delete/68268/integrated
Del: useless -- http://master.php.net/note/delete/68268/useless
Del: bad code -- http://master.php.net/note/delete/68268/bad+code
Del: spam -- http://master.php.net/note/delete/68268/spam
Del: non-english -- http://master.php.net/note/delete/68268/non-english
Del: in docs -- http://master.php.net/note/delete/68268/in+docs
Del: other reasons-- http://master.php.net/note/delete/68268
Reject -- http://master.php.net/note/reject/68268
Search -- http://master.php.net/manage/user-notes.php