Skip to content

Instantly share code, notes, and snippets.

@chadmandoo
Created December 23, 2014 18:29
Show Gist options
  • Save chadmandoo/26ce91683a6351c60119 to your computer and use it in GitHub Desktop.
Save chadmandoo/26ce91683a6351c60119 to your computer and use it in GitHub Desktop.
<?php
function myfun($num1, $num2, $ctr = 1)
{
for ($i = $num1; $i <= $num2; $i += $ctr)
{
yield $i;
}
}
echo 'Odd numbers: ';
foreach (myfun(1, 7, 2) as $num)
{
echo "$num ";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment