php function numbs for bindec 0011 1111 1111 yield sprintf 04d decbin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php
function numbs()
{
for ($i = 0; $i <= bindec('0011 1111 1111'); ++$i) {
yield sprintf('%04d', decbin($i));
}
}
foreach(numbs() as $numb) {
echo $numb, PHP_EOL;
}