3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_encode($format, $val) { $b64 = base64_encode(pack($format, $val)); return str_replace(array('/', '='), array('_', ''), $b64); } function pack_decode($format, $val) { $b64 = str_replace('_', '/', $val); // un-padded return unpack($format, base64_decode($b64, false)); } function pack_encode_uint16($val) { return pack_encode('S', $val); } function pack_encode_uint32($val) { return pack_encode('N', $val); } function pack_decode_uint16($val) { return pack_decode('S', $val); } function pack_decode_uint32($val) { return pack_decode('N', $val); } $max = 32767; $n = 20; $step = intval($max/$n); for ($i=0; $i<=$n; $i++) { $val = $i*$step; $uint16 = pack_encode_uint16($val); $uint32 = pack_encode_uint32($val); $str = base64_encode(strval($val)); echo "$uint16 $uint32 $str $val\n"; }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
AAA AAAAAA MA== 0 ZgY AAAGZg MTYzOA== 1638 zAw AAAMzA MzI3Ng== 3276 MhM AAATMg NDkxNA== 4914 mBk AAAZmA NjU1Mg== 6552 _h8 AAAf_g ODE5MA== 8190 ZCY AAAmZA OTgyOA== 9828 yiw AAAsyg MTE0NjY= 11466 MDM AAAzMA MTMxMDQ= 13104 ljk AAA5lg MTQ3NDI= 14742 _D8 AAA__A MTYzODA= 16380 YkY AABGYg MTgwMTg= 18018 yEw AABMyA MTk2NTY= 19656 LlM AABTLg MjEyOTQ= 21294 lFk AABZlA MjI5MzI= 22932 +l8 AABf+g MjQ1NzA= 24570 YGY AABmYA MjYyMDg= 26208 xmw AABsxg Mjc4NDY= 27846 LHM AABzLA Mjk0ODQ= 29484 knk AAB5kg MzExMjI= 31122 +H8 AAB_+A MzI3NjA= 32760

preferences:
216.74 ms | 407 KiB | 325 Q