The array is like this. now we want to make the following results. thank you for your help.
The array is like this.
Now we want to achieve the following results:
Thank you!
Reply content:
The array is like this.
Now we want to achieve the following results:
Thank you!
Append an array
The array_merge_recursive () function is the same as the array_merge () function. two or more numbers can be combined to form a combined array. the difference between the two is that when a key in an input array already exists in the result array, the function will adopt different processing methods. array_merge () overwrites the existing key/value pairs and replaces them with the key/value pairs in the current input array. array_merge_recursive () merges the two values, form a new array and use the original key as the array name. Another form of array merging is recursively appending an array. The format is:
Array_merge_recursive (array array1, array array2 [..., Array arrayN])
The program example is as follows:
'$ Fruit1 = array ("apple" => "red", "banana" => "yellow ");
$ Fruit2 = array ("pear" => "yellow", "apple" => "green ");
$ Result = array_merge_recursive ($ fruit1, $ fruit2 );
Print_r ($ result );
// Output
// Array ([apple] => Array ([0] => red [1] => green) [banana] => yellow [pear] => yellow )'
Array_merge
array_merge_recursive