3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gray_to_binary($value) { $dec = 0; $bits = floor(log($value, 2)); for ($i = $bits; $i >= 0; $i--) { $dec = $dec | (((($dec >> ($i + 1)) ^ ($value >> $i)) & 1) << $i); } return $dec; } function iterate_gray($value) { // get the equivalent starting binary value $code = decbin($value); yield $code; $len = strlen($code); $count = gray_to_binary($value); while ($count > 0) { // flip the bit which corresponds to the least signficiant 1 bit in $count $xor = 1; while (($count & $xor) == 0) $xor <<= 1; $value ^= $xor; yield sprintf("%0{$len}b", $value); $count--; } } foreach (iterate_gray(8) as $code) { echo $code . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
1000 1001 1011 1010 1110 1111 1101 1100 0100 0101 0111 0110 0010 0011 0001 0000

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.97 ms | 405 KiB | 5 Q