Home > Article > Backend Development > PHP method to merge associative and non-associative arrays through array_merge() function_PHP tutorial
This article mainly introduces how PHP merges associative and non-associative arrays through the array_merge() function. Involving the array_merge() function operation array merging skills in php, friends who need it can refer to it
The example in this article describes how PHP merges associative and non-associative arrays through the array_merge() function. 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.
?
3 4
5
6
|
$beginning = 'foo'; $end = array(1 => 'bar'); $result = array_merge((array)$beginning, (array)$end);
|
1 |
Array ( [0] => foo [1] => bar ) |