Array merging troubles...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shableep
Forum Newbie
Posts: 1
Joined: Thu May 18, 2006 2:25 am

Array merging troubles...

Post 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.
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Post 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;
Post Reply