我要的是一个efficient(不循环)方式,该方式合并阵列first element of the resulting array是first element of the first array,the second element of the resulting array是the second element of the second array(或者)...等
例:
$arr1 = array(1, 3, 5);
$arr2 = array(2, 4, 6);
$resultingArray = array(1, 2, 3, 4, 5, 6);
Run Code Online (Sandbox Code Playgroud)
假设两个阵列具有相同的长度.
$arr1 = array(1, 3, 5);
$arr2 = array(2, 4, 6);
$new = array();
for ($i=0; $i<count($arr1); $i++) {
$new[] = $arr1[$i];
$new[] = $arr2[$i];
}
var_dump($new);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3671 次 |
| 最近记录: |