Combine PHP array as something [duplicate]

If your first two arrays has the same length, you can use a loop to get the array you want:

<?PHP
$arr1= array("A","B","C");
$arr2= array("1","2","3");
$arr3=[];
for($i = 0; $i < count($arr1); $i++)
    array_push($arr3, $arr1[$i], $arr2[$i]);
?>

It will return:

$arr3= array(“A”,”1″,”B”,”2″,”C”,”3″);

Leave a Comment