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
You need to loop it (possibly using a function like array_map() for that), there is no PHP function to automatically perform a deep copy of an array.
array_map()