Manual PHP Înapoi Înainte array_map Description Exemplu 1. array_map() example function cube( $n) {return $n*$n*$n;} $a = array(1, 2, 3, 4, 5); $b = array_map("cube", $a); print_r($b); Exemplu 2. array_map() - using more arrays function show_Spanish( $n, $m) {return "The number $n is called $m in Spanish";} function map_Spanish($n, $m) {return array ($n = $m);} $a = array(1, 2, 3, 4, 5); $b = array("uno", "dos", "tres", "cuatro", "cinco"); $c = array_map("show_Spanish", $a, $b); print_r($c); $d = array_map("map_Spanish", $a, $b); print_r($d); Exemplu 3. $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); See also array_filter() and array_reduce(). Înapoi Acasã Înainte Sus