array_merge($array1 [, $array2 [, $array3 ...]])
引數 $array1、$array2、... 、$arrayn 為若干個要合併的陣列。<?php $arr1 = array( 'id' => 1234, 'url' => 'http://c.biancheng.net/php/', 'language' => 'PHP', 'article' => '陣列排序函數', 6 => '345' ); $arr2 = array( 'id' => 5678, 6 => 34, 8 => 26, 11 => 89 ); echo '<pre>'; $arr = array_merge($arr1, $arr2); echo '將 $arr1 與 $arr2 合併,結果為:'; print_r($arr); $array = array_merge($arr2); echo '如果只傳入 $arr2 一個引數,結果為:'; print_r($array); ?>執行結果為:
將 $arr1 與 $arr2 合併,結果為:Array
(
[id] => 5678
[url] => http://c.biancheng.net/php/
[language] => PHP
[article] => 陣列排序函數
[0] => 345
[1] => 34
[2] => 26
[3] => 89
)
如果只傳入 $arr2 一個引數,結果為:Array
(
[id] => 5678
[0] => 34
[1] => 26
[2] => 89
)