3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function gdr_encode($val) { $str = ''; while ($val > 0) { $str .= chr($val & 0xFF); $val = $val >> 8; } return str_replace(array('/', '='), array('_', ''), base64_encode($str)); } function gdr_decode($bin) { $str = base64_decode(str_replace('_', '/', $bin)); $val = 0; for ($i=0; $i<strlen($str); $i++) { $val |= ord($str[$i]) << $i*8; } return $val; } mt_srand(42); // seed rng for semi-consistent values for ($i=0; $i<32; $i++) { $val = 1<<$i; $val += mt_rand(0, $val/2); $enc = gdr_encode($val); $dec = gdr_decode($enc); if ($val === $dec) { echo "$enc $val\n"; } else { echo "$enc $valĀ ERROR: gdr_decode($enc) == $dec\n"; } }
based on 1t81Z
Output for 7.1.0
AQ 1 Aw 3 BQ 5 DA 12 EA 16 Jg 38 WQ 89 uw 187 QAE 320 EQI 529 KAQ 1064 cgg 2162 tBU 5556 Ky0 11563 oUo 19105 wpc 38850 oXgB 96417 1cYC 181973 9uMF 386038 2nYI 554714 7QUV 1377773 Tfwg 2161741 P_tL 4979519 dOaU 9758324 QfQaAQ 18543681 rfxEAg 38075565 CttbBA 73128714 gQkzCA 137562497 uhSMFg 378279098 rJMBLg 771855276 E5nzTg 1324587283 nkQTng 2652062878
Output for 5.2.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
AQ 1 Aw 3 Bg 6 DA 12 Eg 18 Iw 35 TQ 77 mQ 153 FAE 276 cgI 626 swU 1459 nAs 2972 dxA 4215 sCg 10416 ZUQ 17509 _6o 43775 8UwB 85233 kyQC 140435 p5cE 300967 g5oK 694915 KCoQ 1059368 cg4v 3083890 gQlf 6228353 OzWu 11416891 j8YVAQ 18204303 _kTwAg 49300734 trdsBA 74233782 jpP6Cw 200971150 pmB0EQ 292839590 lWcJIA 537487253 InPeRQ 1172206370 kyshmA 2552310675
Output for 4.3.0 - 5.2.0
AQ 1 Ag 2 BQ 5 DA 12 Fw 23 LQ 45 Vg 86 tw 183 aQE 361 9AI 756 ggQ 1154 6wo 2795 SBE 4424 cCg 10352 C1U 21771 BoI 33286 QXgB 96321 fLwC 179324 Fw0E 265495 0m8J 618450 H0sV 1395487 1XQn 2585813 ZcRY 5817445 MQKE 8651313 p9xJAQ 21617831 XVsAAg 33577821 s5CuBQ 95326387 sm_eCg 182349746 jzjjFA 350435471 vr0TIg 571719102 P2YATA 1275094591 +vJTsQ 2975068922