PHP array_merge_recursive()函数与示例
PHP array_merge_recursive()函數 (PHP array_merge_recursive() function)
array_merge_recursive() function is used to merge two or more arrays, it returns a new array with merged elements. The only difference between array_merge() and array_merge_recursive() function is: "It merges the values having the same key as an array instead of overriding the values."
array_merge_recursive()函數用于合并兩個或多個數組,它返回一個具有合并元素的新數組。 “ array_merge()和array_merge_recursive()函數之間的唯一區別是: “它合并與數組具有相同鍵的值,而不是覆蓋這些值。”
Syntax:
句法:
array_merge_recursive(array1, array2,...);It accepts two or more arrays and returns a new array with merged elements.
它接受兩個或多個數組,并返回帶有合并元素的新數組。
Examples:
例子:
Input:$arr1 = array("a" => "Hello", "b" => "Hi");$arr2 = array("a" => "Okay!", "d" => "Nothing");Output:Array([a] => Array ([0] => Hello [1] => Okay! )[b] => Hi[d] => Nothing)PHP code:
PHP代碼:
<?php$arr1 = array("a" => "Hello", "b" => "Hi");$arr2 = array("a" => "Okay!", "d" => "Nothing");//merging arrays$arr3 = array_merge_recursive($arr1, $arr2);//printing print_r ($arr3); ?>Output
輸出量
Array ([a] => Array ([0] => Hello [1] => Okay! )[b] => Hi[d] => Nothing )翻譯自: https://www.includehelp.com/php/array_merge_recursive-function-with-example.aspx
總結
以上是生活随笔為你收集整理的PHP array_merge_recursive()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颐和园发朋友圈的句子
- 下一篇: 地下城与勇士守护者祭坛在哪