The following three code snippets show the effect of using references in scalar variables, arrays and objects under different circumstances.
In any case the result is the expected one if you stick to the concept that a reference is an alias to a variable. After assigning by reference ( no matter if $a =& $b or $b =& $a ) both variable names refer to the same variable.
References with scalars
<?php
$a = 1;
$b =& $a;
$b = 2;
echo "$a,$b\n"; $a = 3;
echo "$a,$b\n"; $c =& $d;
$c = 4;
echo "$c,$d\n"; ?>
References with arrays
<?php
$a = 1;
$b = 2;
$c = array(&$a, &$b);
$a = 3;
$b = 4;
echo "c: $c[0],$c[1]\n"; $c[0] = 5;
$c[1] = 6;
echo "a,b: $a,$b\n"; $d = array(1,2);
$e =& $d;
$d[0] = 3;
$d[1] = 4;
echo "e: $e[0],$e[1]\n"; $e[0] = 5;
$e[1] = 6;
echo "d: $d[0],$d[1]\n"; $e = 7;
echo "d: $d\n"; $a = 1;
$b = 2;
$f = array(&$a,&$b);
foreach($f as $x) $x = 3;
echo "a,b: $a,$b\n"; foreach($f as &$x) $x = 3;
echo "a,b: $a,$b\n"; $x = 4;
echo "a,b: $a,$b\n"; unset($x);
$x = 5;
echo "a,b: $a,$b\n"; ?>
References with objects
<?php
$a = 1;
$b = new stdClass();
$b->x =& $a;
$a = 2;
echo "b->x: $b->x\n"; $b->x = 3;
echo "a: $a\n"; $c = new stdClass();
$c->x = 1;
$d =& $c;
$d->x = 2;
echo "c->x: $c->x\n"; $d = new stdClass();
$d->y = 3;
echo "c->y: $c->y\n"; echo "c->x: $c->x\n"; ?>