Many companies still use the FizzBuzz coding challenge as a simple way to filter out candidates. My current company used a variation of FizzBuzz for my interview. I was thinking about that challenge recently and working on converting an if/else statement to a match expression in PHP when I thought of a neat way to solve the FizzBuzz problem using the new match expression in PHP 8.0.

$fb = array_map(fn($i) => match(0) {
$i % 15 => 'FizzBuzz',
$i % 5 => 'Buzz',
$i % 3 => 'Fizz',
default => $i
}, range(1, 100));

Obviously you’d need to loop through the results, but it’s a nice compact way of solving the problem.