Is there a function to make a copy of a PHP array to another?

前端 未结 19 2228
我寻月下人不归
我寻月下人不归 2020-12-07 06:44

Is there a function to make a copy of a PHP array to another?

I have been burned a few times trying to copy PHP arrays. I want to copy an array defined inside an obj

相关标签:
19条回答
  • 2020-12-07 07:37
    foreach($a as $key => $val) $b[$key] = $val ;
    

    Preserves both key and values. Array 'a' is an exact copy of array 'b'

    0 讨论(0)
提交回复
热议问题