Created
October 1, 2019 09:31
-
-
Save portapipe/b30de4ab3bc12ea87070276033518c03 to your computer and use it in GitHub Desktop.
PHP Binary combinations of a given length
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$bits = 4; //Number of combinations | |
for($i=0;$i<=(pow(2,$bits)-1);$i++){ | |
$bin = str_pad(decbin($i), $bits, '0', STR_PAD_LEFT); | |
echo '<pre>';var_dump($bin);echo '</pre>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment