Here is a simple conversion.
<?php
define('LENGTH', 3);
function print_binary($n)
{
$bit = 1<<LENGTH - 1;
while($bit)
{
echo $n & $bit ? 1 : 0;
$bit >>= 1;
}
echo "\n";
}
$n = 1<<LENGTH;
for($i = 0; $i < $n; $i++)
print_binary($i);
?>
3
solved convert C to PHP [closed]