- array_map: documentation ( source)
- var_dump: documentation ( source)
<?php
$factor = 10;
// pre PHP 7.4
$nums = array_map(function($n) use ($factor) {
return $n * $factor;
}, [1,2,3,4]);
var_dump($nums);
// PHP 7.4
$nums = array_map(fn($n) => $n * $factor, [1, 2, 3, 4]);
var_dump($nums);