<?php
$foo_count = $bar_count = 0;
foreach (range(1, 20) as $number ) { echo $number;
echo ' ';
if ($number % 3 == 0 && $number %5 == 0) {
echo "foobar ";
$foo_count++;
$bar_count++;
} elseif ($number % 3 == 0) {
echo "foo ";
$foo_count++;
} elseif ($number % 5 == 0) {
echo "bar ";
$bar_count++;
}
}
echo "<br>\n";
echo "foo: $foo_count times listed<br>\n";
echo "bar: $bar_count times listed<br>";
PD9waHAKCiRmb29fY291bnQgPSAkYmFyX2NvdW50ID0gMDsKZm9yZWFjaCAocmFuZ2UoMSwgMjApIGFzICRudW1iZXIgKSB7CiAgICBlY2hvICRudW1iZXI7CiAgICBlY2hvICcmbmJzcDsnOwoKICAgIGlmICgkbnVtYmVyICUgMyA9PSAwICYmICRudW1iZXIgJTUgPT0gMCkgewogICAgICAgIGVjaG8gImZvb2JhciAiOwogICAgICAgICRmb29fY291bnQrKzsKICAgICAgICAkYmFyX2NvdW50Kys7CgogICAgfSBlbHNlaWYgKCRudW1iZXIgJSAzID09IDApICB7CiAgICAgICAgZWNobyAiZm9vICI7CiAgICAgICAgJGZvb19jb3VudCsrOwoKICAgIH0gZWxzZWlmICgkbnVtYmVyICUgNSA9PSAwKSB7CiAgICAgICAgZWNobyAiYmFyICI7CiAgICAgICAgJGJhcl9jb3VudCsrOwogICAgfQp9CgplY2hvICI8YnI+XG4iOwplY2hvICJmb286ICRmb29fY291bnQgdGltZXMgbGlzdGVkPGJyPlxuIjsKZWNobyAiYmFyOiAkYmFyX2NvdW50IHRpbWVzIGxpc3RlZDxicj4iOw==