gpt4 book ai didi

PHP : How to merge child arrays?

转载 作者:行者123 更新时间:2023-12-02 03:55:26 25 4
gpt4 key购买 nike

我有:

$colors = array(
'apple' => array('green', 'red'),
'grape' => array('green', 'purple'),
);

$countries = array(
'apple' => array('china', 'usa')
'grape' => array('spain', 'france')
);

预期输出:

$result = array(
'apple' => array('green', 'red', 'china', 'usa'),
'grape' => array('green', 'purple', 'spain', 'france'),
);

我怎样才能实现这个目标?

最佳答案

$result = array_merge_recursive($colors, $countries);

了解更多:http://php.net/manual/en/function.array-merge-recursive.php

关于PHP : How to merge child arrays?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44115534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com