Example 3. Creating an array of arrays
<?php
$a = array(1, 2, 3, 4, 5);
$b = array("one", "two", "three",
"four", "five");
$c = array("uno", "dos", "tres",
"cuatro", "cinco");
$d = array_map(null, $a, $b, $c);
print_r($d);
?>
The printout of the program above will be:
Array
(
[0] => Array
(
[0] => 1
[1] => one
[2] => uno
)
[1] => Array
(
[0] => 2
[1] => two
[2] => dos
)
[2] => Array
(
[0] => 3
[1] => three
[2] => tres
)
[3] => Array
(
[0] => 4
[1] => four
[2] => cuatro
)
[4] => Array
(
[0] => 5
[1] => five
[2] => cinco
)
)
See also array_filter(), array_reduce(), and array_walk().
|