在php中合并两个数组有问题,我有一个数组。
$array1=array('test1','test2');
数组2是phpoffice的,所以我想把两个数组结合起来
array1 :数组(2){ => string(5) "test1“1=> string(5) "test2”}
array2 :数组(1){ =>数组(2){ =>字符串(3) "ali“1=>字符串(10) "google.com”}}
结果,我想要两个数组相等于下面
"test1"=>字符串(3) "ali“"test2"=> string(10) "google.com”}
发布于 2022-11-26 12:36:20
这就是array_combine()的目的:
<?php
$input1 = ["test1", "test2"];
$input2 = [["ali", "google.com"]];
$output = array_combine($input1, $input2[0]);
print_r($output);产出如下:
Array
(
[test1] => ali
[test2] => google.com
)https://stackoverflow.com/questions/74582017
复制相似问题