3v4l.org

run code in 300+ PHP versions simultaneously
<?php function string_shift_left($input, $inputlen, $bits, &$output = null) { $skip = (int) ($bits / 8); $copylen = (int) ($inputlen - $skip); $offset = $bits % 8; $mask = (0xff >> $offset) << (8 - $offset); $output = str_pad('', $inputlen + 1, "\x00"); var_dump($skip, $copylen, $offset, $mask, $output); if ($offset == 0) { /* Shifting multiples of 8 allows us to simply copy the relevant bytes */ for ($i = 0; $i < $copylen; $i++) { $output[$i] = $input[$i + $skip]; } return; } for ($i = 0; $i < $copylen; $i++) { $left = (ord($input[$i + $skip]) << $offset); $right = (ord($input[$i + $skip + 1]) & $mask) >> $offset; printf("%08b|%08b\n", $left, $right); $output[$i] = chr($left | $right); } } //0b000100010001000100000000; string_shift_left("abc\x00", 3, 2, $output); for ($i = 0; $i < strlen($output); $i++) { printf('%08b|', ord($output[$i])); }

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.60.0080.00818.43
8.3.50.0150.00321.98
8.3.40.0040.01118.84
8.3.30.0160.00019.17
8.3.20.0070.00020.38
8.3.10.0040.00421.92
8.3.00.0080.00022.50
8.2.180.0100.01016.75
8.2.170.0040.01122.96
8.2.160.0030.01319.34
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0080.00017.50
8.2.110.0040.00422.01
8.2.100.0070.00319.27
8.2.90.0050.00319.27
8.2.80.0000.00817.97
8.2.70.0080.00017.63
8.2.60.0070.00317.93
8.2.50.0040.00418.07
8.2.40.0000.00817.99
8.2.30.0080.00418.20
8.2.20.0000.00817.75
8.2.10.0040.00417.77
8.2.00.0000.00717.84
8.1.280.0140.00325.92
8.1.270.0040.00422.23
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00623.61
8.1.230.0040.00719.07
8.1.220.0080.00017.91
8.1.210.0030.00618.77
8.1.200.0060.00317.35
8.1.190.0050.00317.54
8.1.180.0050.00318.10
8.1.170.0000.00818.71
8.1.160.0000.00722.11
8.1.150.0040.00418.62
8.1.140.0070.00017.46
8.1.130.0000.00717.73
8.1.120.0000.00717.41
8.1.110.0040.00417.48
8.1.100.0000.00717.33
8.1.90.0000.00717.45
8.1.80.0050.00217.50
8.1.70.0030.00317.50
8.1.60.0040.00417.62
8.1.50.0000.00817.46
8.1.40.0030.00617.57
8.1.30.0040.00417.52
8.1.20.0060.00317.55
8.1.10.0000.00717.57
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0040.00417.16
8.0.280.0040.00418.46
8.0.270.0030.00317.39
8.0.260.0060.00016.76
8.0.250.0000.00716.90
8.0.240.0040.00416.99
8.0.230.0030.00316.96
8.0.220.0050.00216.88
8.0.210.0030.00316.92
8.0.200.0000.00816.84
8.0.190.0040.00316.86
8.0.180.0080.00016.86
8.0.170.0000.00816.84
8.0.160.0050.00316.86
8.0.150.0030.00316.80
8.0.140.0040.00416.81
8.0.130.0060.00013.34
8.0.120.0040.00416.88
8.0.110.0050.00316.85
8.0.100.0070.00016.85
8.0.90.0040.00416.93
8.0.80.0070.01016.88
8.0.70.0030.00516.70
8.0.60.0040.00416.93
8.0.50.0080.00016.89
8.0.30.0090.01017.05
8.0.20.0050.01317.40
8.0.10.0060.00316.82
8.0.00.0050.01316.75
7.4.330.0040.00315.00
7.4.320.0030.00316.62
7.4.300.0050.00216.55
7.4.290.0030.00316.63
7.4.280.0070.00016.52
7.4.270.0070.00016.63
7.4.260.0030.00316.41
7.4.250.0060.00316.60
7.4.240.0040.00316.63
7.4.230.0030.00316.58
7.4.220.0030.01416.59
7.4.210.0070.00916.65
7.4.200.0070.00016.73
7.4.190.0030.00316.39
7.4.160.0060.00916.46
7.4.150.0100.00717.40
7.4.140.0090.00917.86
7.4.130.0080.00916.54
7.4.120.0140.00516.54
7.4.110.0060.01216.45
7.4.100.0090.00916.45
7.4.90.0070.01016.55
7.4.80.0000.01919.39
7.4.70.0090.00916.50
7.4.60.0150.00616.65
7.4.50.0000.00816.50
7.4.40.0070.00422.77
7.4.30.0120.00616.60
7.4.00.0130.00315.09
7.3.330.0000.00513.25
7.3.320.0030.00313.46
7.3.310.0070.00016.21
7.3.300.0030.00316.38
7.3.290.0130.00316.38
7.3.280.0120.00416.38
7.3.270.0110.00617.40
7.3.260.0040.01216.62
7.3.250.0080.01016.55
7.3.240.0070.01016.41
7.3.230.0120.00616.59
7.3.210.0090.00916.55
7.3.200.0130.00519.39
7.3.190.0030.01616.66
7.3.180.0090.00616.27
7.3.170.0100.00716.51
7.3.160.0030.01316.40
7.3.120.0100.00314.66
7.2.330.0070.01016.61
7.2.320.0030.02016.76
7.2.310.0160.00716.73
7.2.300.0130.01016.39
7.2.290.0040.01316.73
7.2.00.0000.01319.10
7.1.70.0080.00017.18
7.1.60.0030.00717.25
7.1.50.0030.01716.66
7.1.00.0030.07322.40
7.0.200.0040.01216.74
7.0.140.0100.07022.04
7.0.60.0130.08319.93
7.0.50.0000.04717.90
7.0.40.0070.04020.13
7.0.30.0370.07320.27
7.0.20.0130.04720.20
7.0.10.0070.04020.25
7.0.00.0030.08720.32
5.6.280.0030.07321.09
5.6.210.0000.04320.52
5.6.200.0130.07718.16
5.6.190.0070.05720.63
5.6.180.0030.05720.34
5.6.170.0270.05720.54
5.6.160.0070.07720.51
5.6.150.0070.07718.12
5.6.140.0030.08718.14
5.6.130.0200.07318.15
5.6.120.0170.07721.13
5.6.110.0100.06321.13
5.6.100.0000.04320.99
5.6.90.0000.06320.96
5.6.80.0070.07720.39
5.6.70.3470.03720.51
5.5.350.0270.07320.33
5.5.340.0100.06717.98
5.5.330.0030.07720.47
5.5.320.4030.04720.29
5.5.310.0300.07320.41
5.5.300.0000.07718.04
5.5.290.0100.07717.99
5.5.280.0130.08020.74
5.5.270.0130.08020.74
5.5.260.0070.09320.82
5.5.250.0100.07720.70
5.5.240.0200.07320.34
5.4.450.0200.06019.49
5.4.440.0700.06019.41
5.4.430.0100.05319.51
5.4.420.0130.05319.68
5.4.410.0130.07319.52
5.4.400.0130.04718.79
5.4.390.0070.05718.54
5.4.380.0230.05318.63
5.4.370.0170.06018.78
5.4.360.0170.05018.70
5.4.350.0170.05318.48
5.4.340.0230.04718.73
5.4.320.0060.03712.51
5.4.310.0040.05212.51
5.4.300.0080.04212.52
5.4.290.0060.04412.51
5.4.280.0070.03512.40
5.4.270.0100.07018.84
5.4.260.0130.04719.09
5.4.250.0070.06718.99
5.4.240.0170.05718.70
5.4.230.0170.07018.75
5.4.220.0030.06018.90
5.4.210.0130.07318.75
5.4.200.0130.05718.95
5.4.190.0100.06718.95
5.4.180.0170.05318.83
5.4.170.0070.08318.95
5.4.160.0070.05719.00
5.4.150.0170.07318.95
5.4.140.0070.06316.55
5.4.130.0130.06016.40
5.4.120.0170.04016.55
5.4.110.0130.06016.64
5.4.100.0100.07316.43
5.4.90.0070.07716.64
5.4.80.0100.06316.63
5.4.70.0100.05316.34
5.4.60.0130.05716.31
5.4.50.0130.06716.45
5.4.40.0100.04716.57
5.4.30.0100.06316.34
5.4.20.0100.07716.38
5.4.10.0100.05316.30
5.4.00.0100.06716.03
5.3.290.0060.04612.80
5.3.280.0170.06014.52
5.3.270.0030.06014.80
5.3.260.0170.06014.60
5.3.250.0230.05314.62
5.3.240.0170.05014.59
5.3.230.0170.06314.69
5.3.220.0130.04714.41
5.3.210.0070.05314.80
5.3.200.0170.04714.66
5.3.190.0200.06314.74
5.3.180.0030.07314.65
5.3.170.0030.08014.48
5.3.160.0100.05714.41
5.3.150.0030.05314.56
5.3.140.0100.05014.63
5.3.130.0030.05314.56
5.3.120.0130.05314.47
5.3.110.0070.07714.62
5.3.100.0100.05314.06
5.3.90.0170.04714.04
5.3.80.0100.06014.02
5.3.70.0070.05014.02
5.3.60.0100.06014.07
5.3.50.0200.05314.04
5.3.40.0170.05014.04
5.3.30.0070.05313.89
5.3.20.0130.04013.79
5.3.10.0070.06013.84
5.3.00.0200.04313.82
5.2.170.0170.04311.16
5.2.160.0130.04311.23
5.2.150.0070.04011.33
5.2.140.0070.05011.23
5.2.130.0100.04011.08
5.2.120.0100.04011.20
5.2.110.0070.04010.94
5.2.100.0030.05311.02
5.2.90.0030.05711.20
5.2.80.0130.04310.94
5.2.70.0030.06311.01
5.2.60.0070.04011.14
5.2.50.0100.04011.02
5.2.40.0100.05011.24
5.2.30.0100.06011.06
5.2.20.0070.04010.97
5.2.10.0130.03710.96
5.2.00.0000.05710.92
5.1.60.0030.04710.21
5.1.50.0070.0509.93
5.1.40.0070.0409.97
5.1.30.0100.05010.52
5.1.20.0070.04710.37
5.1.10.0070.03310.28
5.1.00.0000.0439.91
5.0.50.0130.0308.40
5.0.40.0030.0308.28
5.0.30.0030.0438.08
5.0.20.0130.0208.26
5.0.10.0100.0338.23
5.0.00.0030.0438.45
4.4.90.0030.0306.86
4.4.80.0000.0276.86
4.4.70.0130.0136.86
4.4.60.0000.0236.86
4.4.50.0030.0206.86
4.4.40.0100.0376.86
4.4.30.0030.0306.86
4.4.20.0070.0236.86
4.4.10.0100.0236.86
4.4.00.0000.0376.86
4.3.110.0000.0336.86
4.3.100.0030.0276.86
4.3.90.0030.0236.86
4.3.80.0070.0306.86
4.3.70.0000.0306.86
4.3.60.0030.0236.86
4.3.50.0030.0306.86
4.3.40.0100.0236.86
4.3.30.0000.0276.86
4.3.20.0030.0236.86
4.3.10.0030.0206.86
4.3.00.0070.0277.39

preferences:
44.67 ms | 400 KiB | 5 Q