Home >Backend Development >PHP Tutorial >The difference between PHP array addition and array_merge
The powerful functions of PHP array processing lead to various data processing functions.
Among them, array addition and array_merge caused the author to step into a small pit.
1public function action_test54(){ $a = array( '0'=>1567, '1'=>1568, '2'=>1569, '3'=>1570, ); $b = array( '1'=>1571, '2'=>1572, '3'=>1573, '4'=>1574 ); d($a + $b); dd(array_merge($a,$b)); }
Demo2 output:
<small>array</small>(5) ( 0 => <small>integer</small> 1567 1 => <small>integer</small> 1568 2 => <small>integer</small> 1569 3 => <small>integer</small> 1570 4 => <small>integer</small> 1574 )
<small>array</small>(8) ( 0 => <small>integer</small> 1567 1 => <small>integer</small> 1568 2 => <small>integer</small> 1569 3 => <small>integer</small> 1570 4 => <small>integer</small> 1571 5 => <small>integer</small> 1572 6 => <small>integer</small> 1573 7 => <small>integer</small> 1574 )
Conclusion:
$a + $b incremental coverage
The above has introduced the difference between PHP array addition and array_merge, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.