Created
October 30, 2012 06:04
-
-
Save toshimaru/3978567 to your computer and use it in GitHub Desktop.
array_merge VS plus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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