搜索

首页  >  问答  >  正文

合并两个数组的方法

<p>我正在尝试合并两个具有相同键的相似数组</p> <pre class="brush:php;toolbar:false;">Array ( [0] => 4064628 [1] => 4064953 [2] => 4064922 [3] => 4064870 [4] => 4064789 [5] => 4064631 [6] => 4065044 [7] => 4064942 [8] => 4064938 [9] => 4064936 ) Array ( [0] => 165020 [1] => 165026 [2] => 165025 [3] => 165023 [4] => 165024 [5] => 165021 [6] => 165027 [7] => 165043 [8] => 165042 [9] => 165045 )</pre> <p>但是当我使用<em>array_merge</em>或<em>array_merge_recursive</em>时,输出结果相同:</p> <pre class="brush:php;toolbar:false;">Array ( [0] => 4064628 [1] => 4064953 [2] => 4064922 [3] => 4064870 [4] => 4064789 [5] => 4064631 [6] => 4065044 [7] => 4064942 [8] => 4064938 [9] => 4064936 [10] => 165020 [11] => 165026 [12] => 165025 [13] => 165023 [14] => 165024 [15] => 165021 [16] => 165027 [17] => 165043 [18] => 165042 [19] => 165045 )</pre> <p>但是我想要像这样的结果:</p> <pre class="brush:php;toolbar:false;">Array ( [0] => Array ( [0] => 4064628 [1] => 165020 ) [1] => Array ( [0] => 4064935 [1] => 165026 ) [2] => Array ( [0] => 4064922 [1] => 165025 ) .......</pre> <p>有人可以帮忙合并这两个数组吗? 这看起来很简单,但有些东西我不明白,我不知道是什么</p>
P粉548512637P粉548512637440 天前503

全部回复(2)我来回复

  • P粉908138620

    P粉9081386202023-09-01 09:20:48

    雷雷

    回复
    0
  • P粉925239921

    P粉9252399212023-09-01 00:06:46

    雷雷

    回复
    0
  • 取消回复