我怎么连接两个数组用PHP? [英] how do I concatenate two arrays with PHP?
本文介绍了我怎么连接两个数组用PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我有两个数组
Array
(
[0] => test
[1] => test 1
[2] => test 2
[3] => test 3
)
和
Array
(
[0] => test
[1] => test 1
[2] => test 2
[3] => test 3
)
我想,所以我得到这样一个数组将它们结合在一起?
I want to combine them together so I get an array like this?
Array
(
[0] => test test
[1] => test 1 test 1
[2] => test 2 test 2
[3] => test 3 test 3
)
我发现很多功能,如 array_merge
和 array_combine
但没有什么做什么,我想做的事情。
I have found lots of functions like array_merge
and array_combine
but nothing that does what I want to do.
任何想法?
先谢谢了。
最大
推荐答案
您可以用做 array_map
:
$combined = array_map(function($a, $b) { return $a . ' ' . $b; }, $a1, $a2));
这篇关于我怎么连接两个数组用PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文