Home > PHP > Function > Arrays > array_map()

array_map()

array_map - Applies the callback to the elements of the given arrays

Syntax

array array_map (callback $callback, array $arr1, array $...)

Arguments

  • callback - Callback function to run for each element in each array.
  • arr1 - An array to run through the callback function.
  • ... - Variable list of array arguments to run through the callback function.

Description

array_map() returns an array containing all the elements of arr1 after applying the callback function to each one. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()

Version

PHP 4.0.6, 5

Return value

Returns an array containing all the elements of arr1 after applying the callback function to each one.