Merge Two or More Arrays Using PHP Example

03-Apr-2023

.

Admin

Merge Two or More Arrays Using PHP Example

Hi Dev,

This tutorial is focused on how to merge arrays in PHP. you'll learn how to merge two arrays in PHP. We will use how to merge the PHP array. if you have a question about how to merge an array in the PHP then I will give a simple example with a solution.

Now, let's see the article on how to merge an array in PHP. it's a simple example of how to merge two arrays in PHP. you can understand the concept of how to merge a PHP array. if you have a question about how to merge an array in the PHP then I will give a simple example with a solution.

Example:


index.php

<?php

$array1 = [1, 2, 3];

$array2 = [4, 5, 6];

// Merge array

$mergeArray = array_merge($array1, $array2);

print_r($mergeArray);

?>

Output:

Array (

[0] => 1

[1] => 2

[2] => 3

[3] => 4

[4] => 5

[5] => 6

)

I hope it could help you...

#PHP