Page 1 of 1

Combine three arrays and make one array.

Posted: Thu Oct 19, 2006 4:58 pm
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]

Posted: Thu Oct 19, 2006 5:05 pm
by jayshields
Presuming you're using PHP5, have you looked at array_combine()? Or array_merge() (PHP4)?

Posted: Thu Oct 19, 2006 8:47 pm
by angelena
Perhaps this can help u start things off :)

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