Send each value of an array to a given function and replace it with the return value of that function.

array:map(ARRAY $array, FUNCTION $callback) : ARRAY

array:map([1,2,3], type:to_string)
#=> [ "1", "2", "3" ] 

array:map([1,2,3], number:dollar_to_words)
#=> [ "one dollar", "two dollars", "three dollars" ]    

array:map([1,2], function($number){ return $number + 1; })
#=> [ 2, 3 ]

array:map([], number:dollar_to_words)
#=> []

Copyright ©2013-2022 SunSed®. All rights reserved.