|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-17 16:10 UTC] arpad@php.net
-Package: Systems problem
+Package: Scripting Engine problem
[2013-07-25 00:38 UTC] tyrael@php.net
-Status: Open
+Status: Not a bug
[2013-07-25 00:38 UTC] tyrael@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 07:00:01 2025 UTC |
Description: ------------ PHP version: 5.3.13 EXAMPLE: <?php $a=array( 'key'=>1 ); foreach($a as &$item) {} $b=array( 'abc'=>2 ); foreach($b as &$item) {} var_dump($a); ?> It will get "array(1) { ["key"]=> &int(2) } " Buy use code like following EXAMPLE: <?php $a=array( 'key'=>1 ); foreach($a as &$item) {} unset($item);//unset the variable $item $b=array( 'abc'=>2 ); foreach($b as &$item) {} var_dump($a); ?> It get the result "array(1) { ["key"]=> int(1) } "; I think that when use refrence in foreach ,it better auto unset the refrenced ITEM and don't need use 'unset' explicitly .