When you assign one array to the next, a copy is made. But because the element at $arr[0]
is a reference rather than a value, a copy of the reference is made, so that at the end, $arr[0]
and $arr2[0]
refer to the same thing.
This is more about references than arrays. Referenced values are not copied. This applies to objects as well. Consider:
$ageRef = 7;
$mike = new stdClass();
$mike->age = &$ageRef; // create a reference
$mike->fruit = 'apple';
$john = clone $mike; // clone, so $mike and $john are distinct objects
$john->age = 17; // the reference will survive the cloning! This will change $mike
$john->fruit = 'orange'; // only $john is affected, since it's a distinct object
echo $mike->age . " | " . $mike->fruit; // 17 | apple
See the first user note on this documentation page and also this one.