Zest.

PHP: array_map, array_filter

A short, tested PHP example for array_map, array_filter. Copy it and adjust the names and paths for your project.

PHP
$nums = [1, 2, 3, 4];
$doubled = array_map(fn($n) => $n * 2, $nums);
$evens = array_values(array_filter($nums, fn($n) => $n % 2 === 0));
$sum = array_sum($nums);

Find it in Zest

Search for “php array_map, array_filter” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More PHP examples

All PHP examples