3v4l.org

run code in 300+ PHP versions simultaneously
<?php function b62e($str) { if(mb_check_encoding($str, 'ASCII')) { $out = ''; $len = strlen($str); for($i=0; $i<$len; $i+=8) { $chunk = substr($str, $i, 8); $outlen = ceil( strlen($chunk)*8/6 );// 8bit/char in, 6bits/char out, round up $hex = bin2hex($chunk);// gmp won't convert from binary, so go via hex $raw = gmp_strval(gmp_init(ltrim($hex, '0'), 16), 62);// gmp doesn't like leading 0s $out .= str_pad($raw, $outlen, '0', STR_PAD_LEFT); } return $out; } return false;// unicode chars not supported } function b62d($str) { if(mb_check_encoding($str, 'ASCII')) { $out = ''; $len = strlen($str); for ($i=0; $i<$len; $i+=11) { $chunk = substr($str, $i, 11); $outlen = floor( strlen($chunk)*6/8 ); //6bit/char in, 8bits/char out, round down $raw = gmp_strval(gmp_init(ltrim($chunk, '0'), 62), 16); //gmp doesn't like leading 0s $pad = str_pad($raw, $outlen * 2, '0', STR_PAD_LEFT); //double output length as as we're going via hex (4bits/char) $out .= pack('H*', $pad); //same as hex2bin } return $out; } return false;// unicode chars not supported } for($i=0; $i<999; $i++){ $encoded = b62e($i); $decoded = b62d($encoded); echo "\t".$i."\t--->\t".$encoded."\t--->\t".$decoded.PHP_EOL; }

Abusive script

This script was stopped while abusing our resources

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.110.0110.00020.94
8.3.100.0090.00316.99
8.3.90.0060.00326.77
8.3.80.0060.00616.75
8.3.70.0110.01117.00
8.3.60.0130.01318.68
8.3.50.0120.01323.81
8.3.40.0200.00322.30
8.3.30.0070.01319.09
8.3.20.0030.00624.18
8.3.10.0060.00324.66
8.3.00.0110.00026.16
8.2.230.0030.00722.58
8.2.220.0160.00624.06
8.2.210.0070.00326.77
8.2.200.0030.00917.00
8.2.190.0140.01116.63
8.2.180.0210.00325.92
8.2.170.0160.00319.38
8.2.160.0130.00722.96
8.2.150.0000.00925.66
8.2.140.0030.00724.66
8.2.130.0030.00726.16
8.2.120.0100.00026.35
8.2.110.0040.00722.35
8.2.100.0070.00718.22
8.2.90.0000.01018.25
8.2.80.0070.00419.11
8.2.70.0000.01117.75
8.2.60.0080.00318.30
8.2.50.0120.00018.07
8.2.40.0060.00318.22
8.2.30.0070.00418.41
8.2.20.0000.00918.48
8.2.10.0030.00619.75
8.2.00.0030.00619.54
8.1.290.0100.00630.84
8.1.280.0100.01325.92
8.1.270.0030.00623.99
8.1.260.0070.00328.09
8.1.250.0050.00528.09
8.1.240.0040.00824.13
8.1.230.0070.00718.02
8.1.220.0030.00718.02
8.1.210.0100.00018.77
8.1.200.0070.00717.61
8.1.190.0030.00717.60
8.1.180.0030.00718.10
8.1.170.0050.00518.98
8.1.160.0030.00619.09
8.1.150.0040.00719.21
8.1.140.0060.00319.07
8.1.130.0060.00320.50
8.1.120.0070.00317.78
8.1.110.0000.01017.67
8.1.100.0050.00917.68
8.1.90.0060.00617.78
8.1.80.0060.00317.75
8.1.70.0090.00017.76
8.1.60.0040.00817.93
8.1.50.0030.00617.73
8.1.40.0060.00617.85
8.1.30.0080.00317.86
8.1.20.0040.00817.93
8.1.10.0000.01017.75
8.1.00.0000.01017.73
8.0.300.0050.00518.77
8.0.290.0030.00917.00
8.0.280.0060.00318.79
8.0.270.0040.00718.36
8.0.260.0030.00618.83
8.0.250.0000.01017.20
8.0.240.0000.00917.23
8.0.230.0000.00917.24
8.0.220.0030.00717.26
8.0.210.0080.00317.10
8.0.200.0060.00617.27
8.0.190.0050.00517.27
8.0.180.0060.00317.20
8.0.170.0080.00317.14
8.0.160.0060.00317.27
8.0.150.0070.00317.18
8.0.140.0030.00917.06
8.0.130.0030.00313.44
8.0.120.0000.01217.14
8.0.110.0070.00317.27
8.0.100.0070.00317.18
8.0.90.0030.00717.10
8.0.80.0090.01517.09
8.0.70.0080.00317.25
8.0.60.0000.01117.23
8.0.50.0060.00317.20
8.0.30.0190.02217.23
8.0.20.0130.01917.28
8.0.10.0070.00317.10
8.0.00.0250.01517.04
7.4.330.0050.00015.55
7.4.320.0030.00716.84
7.4.300.0100.00016.77
7.4.290.0000.01416.57
7.4.280.0000.01116.76
7.4.270.0080.00316.70
7.4.260.0060.00013.29
7.4.250.0030.00916.68
7.4.240.0060.00616.88
7.4.230.0070.00416.51
7.4.220.0050.00516.69
7.4.210.0110.01916.87
7.4.200.0070.00316.67
7.4.130.0140.02016.68
7.4.120.0120.03016.56
7.4.110.0240.01416.74
7.4.100.0270.02416.60
7.4.90.0140.03216.38
7.4.80.0190.02116.75
7.4.70.0160.02516.69
7.4.60.0130.02816.46
7.4.50.0210.01816.66
7.4.40.0180.01816.64
7.4.30.0110.02916.71
7.4.20.0100.02416.77
7.4.10.0230.02316.71
7.4.00.0190.03816.38
7.3.330.0090.00416.70
7.3.320.0050.00013.31
7.3.310.0060.00816.57
7.3.300.0000.00916.60
7.3.290.0070.02516.56
7.3.260.0160.02717.04
7.3.240.0240.01416.62
7.3.230.0210.03016.36
7.3.220.0110.04116.52
7.3.210.0220.02616.52
7.3.200.0240.02116.60
7.3.190.0140.02516.36
7.3.180.0140.02516.29
7.3.170.0270.02016.64
7.3.160.0190.02216.50
7.3.150.0270.02416.97
7.3.140.0320.02017.05
7.3.130.0420.00916.84
7.3.120.0230.02716.78
7.3.110.0270.02316.95
7.3.100.0330.01516.76
7.3.90.0140.03616.93
7.3.80.0310.02616.74
7.3.70.0300.01216.79
7.3.60.0330.01416.77
7.3.50.0270.01916.68
7.3.40.0350.02716.69
7.3.30.0260.03216.63
7.3.20.0440.01716.74
7.3.10.0330.02216.67
7.3.00.0300.01916.84
7.2.340.0160.03317.02
7.2.330.0290.01716.88
7.2.320.0280.01716.66
7.2.310.0260.02416.64
7.2.300.0240.02516.73
7.2.290.0230.01616.84
7.2.280.0310.01416.61
7.2.270.0330.03316.88
7.2.260.0230.03017.06
7.2.250.0220.02216.79
7.2.240.0290.01917.19
7.2.230.0290.01916.82
7.2.220.0320.02417.02
7.2.210.0300.02717.13
7.2.200.0330.03116.93
7.2.190.0370.01416.96
7.2.180.0470.01216.96
7.2.170.0320.03217.01
7.2.160.0370.02516.79
7.2.150.0450.02116.91
7.2.140.0360.02117.04
7.2.130.0360.01716.86
7.2.120.0170.02616.93
7.2.110.0330.02516.98
7.2.100.0380.03016.99
7.2.90.0230.03117.13
7.2.80.0370.02416.94
7.2.70.0290.03217.05
7.2.60.0380.02417.03
7.2.50.0240.03816.93
7.2.40.0400.01317.15
7.2.30.0600.02517.02
7.2.20.0310.03116.96
7.2.10.0370.03816.84
7.2.00.0280.02417.16

preferences:
27.18 ms | 403 KiB | 5 Q