This is just a reminder for me because I always struggle to find a good documentation:
When dealing with simple arrays without numeric indexes in PHP, there are 3 importants things to keep in mind:
- The arguments order passed to the function or used with the
+
sign is important; array_merge
andarray_replace
are interchangeable since their results are identical;- the
+
sign gives the same results asarray_merge
andarray_replace
but the arguments order must be reverse;
So performance wise, the +
sign is better but beware or your arguments orders!!
And here’s a little demo to make it clear to you