We all know that
$a1 = array('foo');
$a2 = $a1;
$a2[0] = 'bar';
// now $a1[0] is foo, and $a2[0] is bar. The array is copied
However, what I remember reading, but cannot confirm Googling, is that the array is not internally copied until it is modified.
$a1 = array('foo');
$a2 = $a1;
$a2[0] = 'bar';
I was wondering if this is true. If so, it will be fine. This would increase performance when iterating through a large array multiple times, but only reading from it anyway (after creating it once).
source
share