3v4l.org

run code in 300+ PHP versions simultaneously
<?php // https://stackoverflow.com/questions/35536141/converting-binary-data-to-ascii-with-php-any-possibility/35536281#35536281 function bin2ascii($input) { $output = ''; for($i=0; $i<strlen($input); $i+=8) { $output .= chr(intval(substr($input, $i, 8), 2)); } return $output; } https://stackoverflow.com/questions/6382738/convert-string-to-binary-then-back-again-using-php/6382880#6382880 function ascii2bin($input) { return array_reduce(str_split($input), fn ($acc, $i) => $acc .= decbin(ord($i))); //return array_reduce(str_split($input), fn ($acc, $i) => $acc .= str_pad(decbin(ord($i)), 8, '0', STR_PAD_LEFT)); } $i = -114514; var_dump( decbin($i)); var_dump( ltrim(decbin($i), $i < 0 ? '1' : '0')); var_dump( ($i < 0 ? '1' : '0') . ltrim(decbin($i), $i < 0 ? '1' : '0')); var_dump( bin2ascii(($i < 0 ? '1' : '0') . ltrim(decbin($i), $i < 0 ? '1' : '0'))); $o = rtrim(base64_encode(bin2ascii(($i < 0 ? '1' : '0') . ltrim(decbin($i), $i < 0 ? '1' : '0'))), '='); var_dump($o); $d = base64_decode($o); var_dump($d); $bits = ascii2bin($d); $signBit = decbin(ord($d))[0]; $paddedBits = str_pad($bits, (strlen($bits) + (strlen($bits) % 8)) / 8, $signBit, STR_PAD_LEFT); var_dump($bits); var_dump($signBit); var_dump($paddedBits); var_dump(intval($paddedBits, 2));
Output for git.master, git.master_jit, rfc.property-hooks
string(64) "1111111111111111111111111111111111111111111111100100000010101110" string(17) "00100000010101110" string(18) "100100000010101110" string(3) "�+" string(4) "kCsC" string(3) "�+" string(16) "1001000010101110" string(1) "1" string(16) "1001000010101110" int(37038)

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:
30.94 ms | 406 KiB | 5 Q