3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_decode($format, $val) { } function pack_encode($format, $val) { $base64 = base64_encode(pack($format, $val)); return str_replace(array('/', '='), array('_', ''), $base64); } function pack_encode_uint16($val) { return pack_encode('S', $val); } function pack_encode_uint32($val) { return pack_encode('S', $val); } $max = 32767; $n = 20; $step = intval($max/$n); for ($i=0; $i<=$n; $i++) { $val = $i*$step; $uint16 = pack_encode_uint16($val); $uin326 = pack_encode_uint32($val); $str = base64_encode(strval($val)); echo json_encode("$uint16 $uint32 $str $val") . "\n"; }

preferences:
36.38 ms | 402 KiB | 5 Q