首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >php数组与数组phpoffice的结合

php数组与数组phpoffice的结合
EN

Stack Overflow用户
提问于 2022-11-26 12:06:00
回答 1查看 27关注 0票数 -3

在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”}

EN

回答 1

Stack Overflow用户

发布于 2022-11-26 12:36:20

这就是array_combine()的目的:

代码语言:javascript
复制
<?php
$input1 = ["test1", "test2"];
$input2 = [["ali", "google.com"]];
$output = array_combine($input1, $input2[0]);
print_r($output);

产出如下:

代码语言:javascript
复制
Array
(
    [test1] => ali
    [test2] => google.com
)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74582017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档