php function gen for bindec 0011 1111 1111 decbin if strlen 10 str_rep

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php
function gen()
{
for ($i = 0; $i <= bindec('0011 1111 1111'); ++$i) {
$s = decbin($i);
$r = '';
if (strlen($s) < 10)
$r = str_repeat('0', (10 - strlen($s)));
$r .= $s;
yield $r;
}
}