I have three arrays Like the following:-
Array
(
[0] => option1
[1] => option2
[2] => option3
)
Array
(
[0] => value1
[1] => value2
[2] => value3
)
Array
(
[0] => 15
[1] => 43
[2] => 12
)
I want to Combine these arrays like following:
Array(
[0] =>Array(
[0] => option1
[1] => value1
[2] => 15
)
[1] =>Array(
[0] => option2
[1] => value2
[2] => 43
)
[2] =>Array(
[0] => option3
[1] => value3
[2] => 12
)
)
I always like this behavior of array_map()
function because it helps me a lot :).See Example #4 Creating an array of arrays at http://php.net/manual/en/function.array-map .I hope this fits your requirement perfectly. :)
$array = array('option1','option2','option3');
$array2 = array('value1','value2','value3');
$array3 = array(15,40,12);
$result = array_map(null,$array,$array2,$array3); //see magic here
print '<pre>';
print_r($result);
print '</pre>';