Array Merge Array_merge
Cases
The code is as follows |
Copy Code |
$array 1 = array (1=> ' 0 '); $array 2 = Array (1=> "data"); $result 3 = Array_merge ($array 2, $array 1),/* results are $array2 and $array1 values, the key name is reassigned * * |
There is another way to use the "+" number directly
The code is as follows |
Copy Code |
A = Array ( ' A ', ); $b = Array ( ' U ', ); $c = $a + $b; Var_dump ($c);
Output Array (1) { [0]=> String (1) "a" } |
Intersection of arrays
This section only introduces some functions, as the usage is very simple, do not want to say more, so as not to complicate the simple things.
Append array
Array array_merge_recursive (array Array1,array array2[...,array Arrayn])
The code is as follows |
Copy Code |
<?php $fruit 1 = Array ("Apple" => "red", "banana" => "yellow"); $fruit 2 = Array ("pear" => "yellow", "apple" => "green"); $result = array_merge_recursive ($fruit 1, $fruit 2); Print_r ($result); Output Array ([Apple] => Array ([0] => red [1] => green) [Banana] => yellow [pear] => yellow) ?> |
The difference set of associative arrays Array_diff () This is not an introduction.