I have an array of objects. I know that objects get assigned by \"reference\" and arrays by \"value\". But when I assign the array, each element of the array is referencing
$a = ['a'=>'A','b'=>'B','c'=>'C']; $b = $a+[]; $a['a'] = 'AA'; // modifying array $a var_export($a); var_export($b);
Result:
array ( 'a' => 'AA', 'b' => 'B', 'c' => 'C', ) array ( 'a' => 'A', 'b' => 'B', 'c' => 'C', )