how do I concatenate the string values of two arrays pairwise with PHP?

后端 未结 9 1342
傲寒
傲寒 2020-12-21 00:43

So I have two arrays

Array
(
[0] => test
[1] => test 1
[2] => test 2
[3] => test 3
)

and

Array
(
[0] => test         


        
9条回答
  •  情书的邮戳
    2020-12-21 01:28

    Here is a one line solution if you are using Php 5.3.0+:

    $result = array_map(function ($x, $y) { return $x.$y; }, $array1, $array2);
    

提交回复
热议问题