用于在数组中查找匹配索引字符串的PHP函数?

Yos*_*ahu 3 php arrays string concat

好吧,我知道可以这样做......

$Array1 = array("Hello, ", "foo", "The quick brown fox jumped ");
$Array2 = array("World!", "bar", "the lazy dog.");
$Array3 = array();
for($x = 0; $x < count($Array1); $x++) {
    $Array3[] = $Array1[$x] . $Array2[$x];
}
// returns this -> ("Hello, World", "foobar", "The quick brown fox jumped over the lazy dog.")
Run Code Online (Sandbox Code Playgroud)

但是有一个原生的PHP函数吗?像这样:

$Array3 = array_concat_strings($Array1, $Array2)
Run Code Online (Sandbox Code Playgroud)

我通过php.net搜索,但没有找到任何东西,但我想确定我没有遗漏任何东西.

dec*_*eze 5

我不认为有这样一个特殊的本机功能,但你可以自己做:

$array3 = array_map(function ($a, $b) { return $a . $b; }, $array1, $array2);
Run Code Online (Sandbox Code Playgroud)