I explained simply how to merge two arrays in PHP Laravel. you will learn how to append two arrays in PHP. you will learn how to merge multiple arrays in PHP. you will do the following things for php merge two array example. We will use the array_merge() function and + sign to merge multiple arrays in PHP. I will give you simple two examples.
Example 1:
<?php
$arrayOne = ["One", "Two", "Three"];
$arrayTwo = ["Four", "Five"];
$newArray = array_merge($arrayOne, $arrayTwo);
var_dump($newArray);
?>
Output: 1
Example: 2
<?php
$arrayOne = [1 => "One", 2 => "Two", 3 => "Three"];
$arrayTwo = [4 => "Four", 5 => "Five"];
$newArray = $arrayOne + $arrayTwo;
var_dump($newArray);
?>