-3

我想将这两个数组合并在一起

Array
(
    [0] => Array
        (
            [type] => Person
            [relevance] => 0.700000
            [count] => 300
            [text] => Chris
        )
)
Array
(
    [0] => Array
        (
            [type] => Person
            [relevance] => 0.900000
            [count] => 400
            [text] => Chris
        )

    [1] => Array
        (
            [type] => Person
            [relevance] => 0.500000
            [count] => 200
            [text] => Tom
        )
)

所以我可能会有这样的结果

Array
(
    [0] => Array
        (
            [type] => Person
            [relevance] => 0.900000
            [count] => 400
            [text] => Chris
        )

    [1] => Array
        (
            [type] => Person
            [relevance] => 0.500000
            [count] => 200
            [text] => Tom
        )
    [2] => Array
        (
            [type] => Person
            [relevance] => 0.700000
            [count] => 300
            [text] => taye
        )
)
4

4 回答 4

1

像这样?

$array_final = array_merge($array_1, $array_2);

参考官方文档站点上的array_merge

于 2013-11-12T11:38:56.280 回答
0

尝试使用foreach

// $array1 is your original array
foreach($array2 as $val) {
     array_push($array2,$val)
}
于 2013-11-12T11:39:20.930 回答
0

使用 array_merge文档并更快地检查文档:D

于 2013-11-12T11:39:57.723 回答
0

您是否搜索过 PHP 文档?

那么array_merge_recursive呢?

于 2013-11-12T11:40:06.707 回答