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

后端 未结 9 1321
傲寒
傲寒 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:23

    Assuming the two arrays are $array1 and $array2

    for($x = 0; $x < count($array2); $x++){
            $array1[$x] = $array1[$x] . ' ' . $array2[$x];
        }
    

提交回复
热议问题