Brent 10/24/2018

array_merge or + in PHP

Read Original

This technical article details the subtle but important differences between using array_merge and the + operator to combine arrays in PHP. It explains how array_merge reindexes numeric keys and overwrites string keys from later arrays, while the + operator only adds elements from the right-hand array if their keys don't already exist in the left-hand array. The post includes code examples and also touches on the behavior of array_merge_recursive.

array_merge or + in PHP

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser