Page 1 of 1

Array merging troubles...

Posted: Thu May 18, 2006 2:32 am
by shableep
So I've been trying to work with this for a while and couldn't come up with any good way to do what I'm looking for.

I have:

Code: Select all

$votes1 = array( 0=> array(13,'topic 1');      
// merge with..
$votes2 = array( 1 => array(23,'topic 2');
and I was hoping for a result like this when merging...

Code: Select all

$votes = array( 0 => array(13,'topic 1'), 
				    1 => array(23,'topic 2');
Not pretty, I know. Lack of sleep and knowledge are definatly not helping. Any help would be awesome.

Posted: Thu May 18, 2006 2:56 am
by someberry
I am pretty sure an addition will do that, of the top of my head. If it doesn't, then consult the excellent PHP manual for array documentation.

Code: Select all

$votes1 = array( 0=> array(13,'topic 1');     
$votes2 = array( 1 => array(23,'topic 2');

$combined_votes = $votes1 + $votes2;