Combine three arrays and make one array.

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
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Combine three arrays and make one array.

Post by amir »

hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello, I have three arrays:
[syntax="php"]
$arr_title=array('stock','fund','currency','comodity');

$arr_get=$_POST['RESULT'];
$arr_name=array($arr_get[0],$arr_get[1],$arr_get[2],$arr_get[3]);

$arr_distance=array('10px','12px','15px','32px');

I'd like to combine those three above arrays and make an one array like:

$arr_comb = array('stock'=>array($arr_get[0],'10px'),'fund'=>array($arr_get[1],'12px'),'currency'=>array($arr_get[2],'15px'),'commodity'=>array($arr_get[3],'32px'));
How can I get it??


hawleyjr | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Presuming you're using PHP5, have you looked at array_combine()? Or array_merge() (PHP4)?
Last edited by jayshields on Thu Oct 19, 2006 5:07 pm, edited 1 time in total.
angelena
Forum Commoner
Posts: 53
Joined: Mon Nov 22, 2004 4:10 am

Post by angelena »

Perhaps this can help u start things off :)

http://sg.php.net/manual/en/function.array-merge.php
Post Reply