note 80482 added to language.references.arent
| From: | frank at osu1 dot php dot net | Date: | Fri, 18 Jan 2008 13:15:58 +0000 |
| Subject: | note 80482 added to language.references.arent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135190@lists.php.net to get a copy of this message | ||
If you have an array like... $a=array('x'=>1,'y'=>2);
you might want have all variables referenced to the array elements.
It works! My function:
function my_make_vars(&$a)
{ foreach ($a as $n=>$v)
{ global $$n;
$$n=$v;
$a[$n] =& $$n;
}
}
$a=array('x'=>1,'y'=>2);
my_make_vars($a);
# Now $x and $a['x'] are the same variable ;-)
print $x.$y.' ';
$a['x']=3;
print $x.' '; # -> 3
$x=4;
print $a['x'].' '; # -> 4
----
Server IP: 217.160.72.57
Probable Submitter: 213.178.64.5 (proxied: 86.103.194.189)
----
Manual Page -- http://www.php.net/manual/en/language.references.arent.php
Edit -- https://master.php.net/note/edit/80482
Del: integrated -- https://master.php.net/note/delete/80482/integrated
Del: useless -- https://master.php.net/note/delete/80482/useless
Del: bad code -- https://master.php.net/note/delete/80482/bad+code
Del: spam -- https://master.php.net/note/delete/80482/spam
Del: non-english -- https://master.php.net/note/delete/80482/non-english
Del: in docs -- https://master.php.net/note/delete/80482/in+docs
Del: other reasons-- https://master.php.net/note/delete/80482
Reject -- https://master.php.net/note/reject/80482
Search -- https://master.php.net/manage/user-notes.php