Skip to main content

How to merge two arrays [closed]





Possible Duplicate:


How to merge these two arrays?







I've got two arrays







array(

'1' => 'string 1',

'2' => 'string 2',

'3' => 'string 3'

)



array(

'a' => 'string a',

'b' => 'string b',

'c' => 'string c'

)







What do I have to do to get this result:







array(

'1' => 'string 1',

'2' => 'string 2',

'3' => 'string 3',

'a' => 'string a',

'b' => 'string b',

'c' => 'string c'

)







Will a simple $result = array_merge($array1, $array2) suffice or just glue them together with PHP $result = $array1 . $array2


Comments

  1. You can use the + operator. The . operator is for strings.

    $result = $array1 + $array2;

    ReplyDelete
  2. . is for string concatenation, so yes, you would use array_merge.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?