Apparently arrays in PHP are passed by value, not by reference as you would intuitively think. To illustrate, consider the following snippet of PHP code:

$a = array(1, 2, 3);
$b = $a;             //This actually creates a copy
$b[1] = 3;           //This does not affect $a

When $b is assigned $a, PHP actually first creates a copy of the array $a, then assign the new array to $b. Essentially when $b is modified, $a is unaffected. The output of the code above follows:

array(3) { [0] => int(1) [1] => int(2) [2] => int(3) }
array(3) { [0] => int(1) [1] => int(3) [2] => int(3) }

I learned this the hard way and spent too much time figuring out what was wrong with my code.

Interesting and confusing enough, class instance objects are passed by reference.