Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:如何组合类似数组的层_Php_Arrays - Fatal编程技术网

PHP:如何组合类似数组的层

PHP:如何组合类似数组的层,php,arrays,Php,Arrays,我有两个数组,我需要像层一样合并它们 第一阵列 Array ( [0]=>1 [1]=>2 [2]=>3 ) 第二阵列 Array ( [0]=>4 [1]=>5 [2]=>6 ) 如何将其与结果相结合 Array ( [0]=>1 [1]=>2 [2]=>3 [3]=>4 [4]=

我有两个数组,我需要像层一样合并它们

第一阵列

Array (
      [0]=>1
      [1]=>2
      [2]=>3
     )
第二阵列

Array (
      [0]=>4
      [1]=>5
      [2]=>6
     )
如何将其与结果相结合

Array (
      [0]=>1
      [1]=>2
      [2]=>3
      [3]=>4
      [4]=>5
      [5]=>6

 )

如果不需要对索引执行任何操作,则正确的函数是array_merge,因此在本例中:

array_merge($a, $b);


“喜欢涂层”是什么意思?@Chris打字错误
array\u merge($array1,$array2),可能是。好吧,“喜欢图层”是什么意思?@RajdeepPaul,谢谢
Interactive mode enabled

php > $a = [1, 2, 3];
php > $b = [4, 5, 6];
php > print_r(array_merge($a, $b));
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
)