我有2个数组,想要将键从第一个数组复制到第二个数组,并在第二个数组上保留值:
阵列:
Array ( [8] => yellow [9] => violet )
Array ( [0] => blue [1] => orange )
期望的输出:
Array ( [8] => yellow [9] => violet )
Array ( [8] => blue [9] => orange )
答案 0 :(得分:3)
获取密钥并合并:
$array2 = array_combine(array_keys($array1), $array2);