我有两个阵列说,
$array1 = array("code" => "E0089",
"desc" => "some description");
$array2 = array("code" => "Code",
"desc" => "Description");
结果数组应为,
$result = array("Code" => "E0089",
"Description" => "some description");
简而言之,我想映射两个数组并创建第三个数组。
答案 0 :(得分:2)
答案 1 :(得分:1)
如果数组的顺序正确:
$result = array_combine($array2, $array1);
否则,您需要进行一些循环:
$result = array();
foreach ($array2 as $key => $val)
$result[$val] = $array1[$key];