How to clone an array of objects in PHP?

后端 未结 15 723
鱼传尺愫
鱼传尺愫 2020-12-13 17:00

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

15条回答
  •  遥遥无期
    2020-12-13 17:49

    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.

提交回复
热议问题