{"id":2141,"date":"2013-10-31T12:36:51","date_gmt":"2013-10-31T10:36:51","guid":{"rendered":"http:\/\/www.nyamsprod.com\/blog\/?p=2141"},"modified":"2013-10-31T13:01:17","modified_gmt":"2013-10-31T11:01:17","slug":"array_merge-vs-array_replace-vs-union","status":"publish","type":"post","link":"https:\/\/nyamsprod.com\/blog\/array_merge-vs-array_replace-vs-union\/","title":{"rendered":"array_merge vs array_replace vs union"},"content":{"rendered":"<div class=\"message warning\">\n<p><strong>Attention:<\/strong> Les informations de ce billet sont susceptibles d'&ecirc;tre obsol&egrave;tes car vieux de plus 2 ans.<\/p>\n<p><strong>Warning: <\/strong> The information you are reading may be obsolete, this post was published more than 2 years ago.<\/p>\n<\/div><p>This is just a reminder for me because I always struggle to find a good documentation:<\/p>\n<p>When dealing with simple arrays without numeric indexes in PHP, there are 3 importants things to keep in mind:<\/p>\n<ol>\n<li>The arguments order passed to the function or used with the <code>+<\/code> sign is important;<\/li>\n<li><code>array_merge<\/code> and <code>array_replace<\/code> are interchangeable since their results are identical;<\/li>\n<li>the <code>+<\/code> sign gives the same results as <code>array_merge<\/code> and <code>array_replace<\/code> but the arguments order must be reverse;<\/li>\n<\/ol>\n<p><strong>So performance wise, the <code>+<\/code> sign is better but beware or your arguments orders!!<\/strong><\/p>\n<p>And here&#8217;s a <a title=\"Demo to demonstrate array_replace vs array_merge vs union in PHP\" href=\"http:\/\/www.nyamsprod.com\/test\/array\/\">little demo to make it clear to you<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Attention: Les informations de ce billet sont susceptibles d&#8217;&ecirc;tre obsol&egrave;tes car vieux de plus 2 ans. Warning: The information you are reading may be obsolete, this post was published more than 2 years ago. This is just a reminder for me because I always struggle to find a good documentation: When dealing with simple arrays [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"aside","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[754,755,412,756],"class_list":["post-2141","post","type-post","status-publish","format-aside","hentry","category-web","tag-array_merge","tag-array_replace","tag-php","tag-union","post_format-post-format-aside"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/2141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/comments?post=2141"}],"version-history":[{"count":5,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/2141\/revisions"}],"predecessor-version":[{"id":2146,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/2141\/revisions\/2146"}],"wp:attachment":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/media?parent=2141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/categories?post=2141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/tags?post=2141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}