- array_map: documentation ( source)
- range: documentation ( source)
- join: documentation ( source)
<?php
$texts = [
3 => 'Fizz',
5 => 'Buzz',
7 => 'Gezz'
];
echo join(', ', array_map(function($x) use ($texts)
{
$y = '';
foreach($texts as $d=>$text)
{
if($x%$d==0) $y .= $text;
}
return $y?:$x;
}, range(1, 100)));