Source Code:
(back to article)
<?php $originalArray = [1, 2, 3, 4, 5, 6, 7]; $newArray = array_map(function ($value) { if ($value % 2 == 0) { return 0; } else { return $value; } }, $originalArray); print_r($newArray);
Result:
Report an issue