$data = Array (' A ', ' B ', ' C ');
foreach($data as $key=>$val) { $val = &$data[$key]; }
Var_dump ($data);
Reply content:
$data = Array (' A ', ' B ', ' C ');
foreach($data as $key=>$val) { $val = &$data[$key]; }
Var_dump ($data);
All the things you see on the display when the computer is powered on, are in memory
Memory, what is the structure of the specific, interested can go to understand the next;
Every unit is like a mailbox, it is a mailbox has its address, this is not difficult to understand it.
$data = array('a', 'b', 'c');foreach($data as $key=>$val) { $val = &$data[$key];}
The above code logic is that the known $data array has three elements, the $data array of the last element of the address, put in $val this mailbox.
At this point we can assign operations to the $val, which can indirectly affect the last element of the $data array
$val = '间接影响';print $data[2];
The specific use of what scenario, can only tell you, when the need to indirectly affect something, use reference assignment.