PHP array_merge vs plus union Operator
The purpose of this post is simple: I’ve seen way too many uses of array_merge function with associative arrays in PHP. In most cases the “+” union operator should have been used and here’s why. Given: <?php$a1 = array(‘abcd’ => ‘value 1’);$a2 = array(1234 => ‘value 2’);var_export(array_merge($a1, $a2));var_export($a1 + $a2);?> The result is as follows: […]