PHP objects in array copy
<p>I got a strange behaviour in PHP with arrays and objects, that I don't understand. Maybe you guys can help me with that.</p>

<p>Creating an array, copy it to another array, change a value in the 2nd array and everything is as expected:</p>

<pre><code>$array1['john']['name'] = 'foo';
$array2 = $array1;
$array2['john']['name'] = 'bar';

echo $array1['john']['name']; // foo
echo $array2['john']['name']; // bar
</code></pre>

<p>Now, if I do this with objects in that array, the object in the copied array holds some kind of a reference?</p>

<pre><code>$array3['john']-&gt;name = 'foo';
$array4 = $array3;
$array4['john']-&gt;name = 'bar';

echo $array3['john']-&gt;name; // bar
echo $array4['john']-&gt;name; // bar
</code></pre>

<p>I would have expected the same behaviour as in the 1st example and I cannot find anything about this in the php docs. Can somebody explain that to me or send me an link to where this is documented?</p>

<p>Thanks!</p>
