Skip to content

Instantly share code, notes, and snippets.

@erikfrerejean
Created March 21, 2013 16:09
Show Gist options
  • Save erikfrerejean/5214256 to your computer and use it in GitHub Desktop.
Save erikfrerejean/5214256 to your computer and use it in GitHub Desktop.
<?php
$max = isset($_GET['iterations']) ? (int) $_GET['iterations'] : 100;
$mod3 = 0;
$mod5 = 0;
$out = array();
for ($i = 0; $i <= $max; $i++)
{
$_o = $i;
$mod3 = $i % 3;
$mod5 = $i % 5;
switch (true)
{
case $mod3 === 0 && $mod5 === 0:
$_o = 'drievijf';
break;
case $mod3 === 0:
$_o = 'drie';
break;
case $mod3 === 0 && $mod5 === 0:
$_o = 'vijf';
break;
}
$out[] = $_o;
}
array_walk($out, function($value) {
echo $value . "\n";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment