Name
array_map
Synopsis
array array_map(mixedcallback
, arrayarray1
[, ... arrayarrayN
])
Creates an array by applying the callback function referenced in
the first parameter to the remaining parameters (provided arrays); the
callback function should take as parameters a number of values equal
to the number of arrays passed into array_map()
. For example:
function
multiply
(
$inOne
,
$inTwo
)
{
return
$inOne
*
$inTwo
;
}
$first
=
(
1
,
2
,
3
,
4
);
$second
=
(
10
,
9
,
8
,
7
);
$array
=
array_map
(
"multiply"
,
$first
,
$second
);
// contains (10, 18, 24, 28)
Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.