Home > Article > Backend Development > PHP uses the array_merge() function to merge associative and non-associative arrays, array_merge array_PHP tutorial
This article describes the example of php using the array_merge() function to merge associative and non-associative arrays . Share it with everyone for your reference. The specific analysis is as follows:
array_merge() is a php function used to merge arrays. The latter array is appended to the end position of the previous one and returns the merged result array.
<?php $beginning = 'foo'; $end = array(1 => 'bar'); $result = array_merge((array)$beginning, (array)$end); print_r($result); ?>
The output results are as follows:
Array ( [0] => foo [1] => bar )
I hope this article will be helpful to everyone’s PHP programming design.