<?php function cube($n) { return $n*$n*$n; } $a = array(1, 2, 3, 4, 5); echo "Au départ : <pre>"; print_r($a); $b = array_map("cube", $a); echo "Après mapping :<br/>"; print_r($b); echo "</pre>";?>
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Après mapping :Array ( [0] => 1 [1] => 8 [2] => 27 [3] => 64 [4] => 125 )