Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://old.hcs.cmc.msu.ru/php/function.array-map.html
Дата изменения: Sun Feb 3 22:34:11 2002 Дата индексирования: Mon Oct 1 21:48:49 2012 Кодировка: |
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()
Usually when using two or more arrays, they should be of equal length because the callback function is applied in parallel to the corresponding elements. If the arrays are of unequal length, the shortest one will be extended with empty elements.
An interesting use of this function is to construct an array of arrays, which can be easily performed by using NULL as the name of the callback function
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() and array_reduce().