View Single Post
Old 12-07-2007, 09:03 PM   #10 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

In extension to Karl's, consider this:

php Code:
$a = 1;
$b =& $a;
$b = 2;

In the above example, both $a and $b now equal 2 because $b has been set as a reference to $a and so whatever $b becomes, $a becomes as well.

In a more complicated example:

php Code:
$aArray = array('Apple', 'Orange', 'Kiwi', 'Pear');
$pItem =& $aArray[2];
$pItem = 'Pitaya';

As $pItem is now a reference to the third item in our array, changing its value will also change the value in the array, so Kiwi now becomes Pitaya.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following 5 Users Say Thank You to Wildhoney For This Useful Post:
Gurnk (12-08-2007), Haris (12-08-2007), Matt83 (12-08-2007), Morishani (12-08-2007), victorius (12-08-2007)