📜  将 php 数组复制到另一个 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:53.093000             🧑  作者: Mango

代码示例1
$arr1 = ['a'=>1, 'b'=>2, 'c'=>3];
$arr2 = $arr1;

unset($arr2['a'];
print_r($arr1);
//['b'=>2, 'c'=>3]
// ------- OR -------
$arr2 = clone $arr1;

unset($arr2['a'];
print_r($arr1);
//['a'=>1, 'b'=>2, 'c'=>3]