📜  克隆数组 php 代码示例

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

代码示例3
$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]