PHP-将循环数组合并为一个

时间:2018-09-14 09:45:32

标签: php arrays

我有两个来自数据库的结果集 第一个是:

Array(
    [0] => Array([vehicle] => BUS NO.1 )
    [1] => Array([vehicle] => BUS NO.2)}

第二个是:

Array([0] => Array(
            [trip_name] => Trip00011
            [running_km] => 5000)
      [1] => Array(
            [trip_name] => Trip00021
            [running_km] => 2400))

我想像下面的数组那样合并这些数组:

Array([0] => Array(
            [vehicle] => BUS NO.1
            [trip_name] => Trip00011
            [running_km] => 5000 )
        [1] => Array(
            [vehicle] => BUS NO.2
            [trip_name] => Trip00011
            [running_km] => 5000)
        [2] => Array(
            [vehicle] => BUS NO.1
            [trip_name] => Trip00021
            [running_km] => 2400 )
        [3] => Array(
            [vehicle] => BUS NO.2
            [trip_name] => Trip00021
            [running_km] => 2400))

实际上,这是我的问题。能否请您帮我做

1 个答案:

答案 0 :(得分:-1)

您可以使用array_merge。 array_merge(array1, array2)