有两个数组:
$arr1 = array
(
[0] => A
[1] => B
[2] => C
[3] => D
)
$arr2 = array
(
[0] => d
[1] => e
[2] => f
)
我想制作一个看起来像这样的多维数组:
$arr3 = array
(
[0] => A => array
(
[0] => d
[1] => e
[2] => f
)
[1] => B
[2] => C
[3] => D
)
我想第一个数组的值应该是第二个数组的键。
这应该可以做到:
$arr3 = $arr1;
$arr3[0] = array('A' => $arr2);
如果要设置dynamiccaly,则可以使用:
$arr3 = $arr1;
$arr3[0] = array($arr3[0] => $arr2);
$arr1 = array('A','B','C','D');
$arr2 = array('d','e','f');
$array = $arr1;
$array[0] = array($arr1[0]=>$arr2);
var_dump($array);
请参阅https://eval.in/645288