<?php
$arr1 = array("Geeks", "g4g");
$arr2 = array("GeeksforGeeks", "Computer science portal");
// Get the merged array in the first array itself.
$arr1 = array_merge($arr1, $arr2);
echo "arr1 Contents:";
// Use for each loop to print all the array elements.
foreach ($arr1 as $value) {
echo $value . "
";
}
?>
let arr1 = ['1', '2'];
let arr2 = ['3', '4'];
let combarr = [].concat(arr1); //define new variable, empty array then concatenating arr1 to it
combarr = combarr.concat(arr2); //combarr = itself, then concatenating arr2 to the end
console.log(combarr); //Expected output: ['1','2','3','4']
<!DOCTYPE html>
<html>
<body>
<p>We will see after clicking the button how two array will join</p>
<button onclick="concateTwoArray()" id="btnClick">Click</button>
<p id="pId"></p>
<script>
function concateTwoArray() {
var twoDay= ["Sunday", "Monday"];
var fiveDay= ["Tuesday", "Wednsday","Thursday", "Friday","Saturday"];
var totalDay = twoDay.concat(fiveDay);
document.getElementById("pId").innerHTML = totalDay ;
}
</script>
</body>
</html>