How to combine 2 php array in different format -


i have 2 arrays -

$a = (1,3,5,7,9); $b = (2,4,6,8,10); 

how can combine these arrays result like:

$c = (1,2,3,4,5,6,7,8,9,10); 

assuming can't sort values after merging because have no natural order, here's i-know-php-tricks way:

$c = call_user_func_array('array_merge', array_map(null, $a, $b)); 

and here's boring, sane way:

$c = array(); foreach ($a $i => $value) {     $c[] = $value;     $c[] = $b[$i]; } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -