Combine two PHP arrays; One as key and another as value -


i have

array a

array (     [0] => 1440:480     [1] => thumb     [2] => 240:auto     [3] => small-thumb     [4] => big-thumb     [5] => detail-img     [6] => tiny-thumb ) 

array b

array (     [0] => 1440x480     [1] => 130xauto     [2] => 240xauto     [3] => 100xauto     [4] => 150xauto     [5] => 650xauto     [6] => 45xauto ) 

how make this?

array c

array (     [1440:480] => 1440x480     [thumb] => 130xauto     [240:auto] => 240xauto     [small-thumb] => 100xauto     [big-thumb] => 150xauto     [detail-img] => 650xauto     [tiny-thumb] => 45xauto ) 

you can use array_combine()

php.net example:

$a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b);  print_r($c); 

output:

array (     [green]  => avocado     [red]    => apple     [yellow] => banana ) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -