Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Created October 30, 2012 06:04
Show Gist options
  • Save toshimaru/3978567 to your computer and use it in GitHub Desktop.
Save toshimaru/3978567 to your computer and use it in GitHub Desktop.
array_merge VS plus
<?php
$ary1 = array(
'matsu' => 'ary1 matsu',
'take' => 'ary1 take',
'ume' => 'ary1 ume',
'ary1' => 'ary1 value',
);
$ary2 = array(
'matsu' => 'ary2 matsu',
'take' => 'ary2 take',
'ume' => 'ary2 ume',
'ary2' => 'ary2 value',
);
print_r (array_merge($ary1, $ary2));
print_r ($ary1 + $ary2);
/*
output:
Array
(
[matsu] => ary2 matsu
[take] => ary2 take
[ume] => ary2 ume
[ary1] => ary1 value
[ary2] => ary2 value
)
Array
(
[matsu] => ary1 matsu
[take] => ary1 take
[ume] => ary1 ume
[ary1] => ary1 value
[ary2] => ary2 value
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment