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) & 0xff; $mask = (0xff >> $offset) << (8 - $offset); $output = str_pad('', $inputlen + 1, "\x00"); echo "$skip $copylen $offset $mask\n"; 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("%02x ", $left | $right); $output[$i] = chr($left | $right); } } //0b000100010001000100000000; $str = "abc\x00"; $bits = 2; string_shift_left($str, strlen($str) - 1, $bits, $output); for ($i = 0; $i < strlen($output); $i++) { printf("\n%02x", 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.70.0120.00316.50
8.3.60.0140.00418.30
8.3.50.0080.01022.05
8.3.40.0080.00818.85
8.3.30.0110.00319.05
8.3.20.0080.00020.33
8.3.10.0080.00022.05
8.3.00.0000.00822.40
8.2.190.0180.00316.63
8.2.180.0070.01116.50
8.2.170.0030.01022.96
8.2.160.0070.00719.20
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.38
8.2.110.0060.00322.14
8.2.100.0040.00819.76
8.2.90.0000.00819.40
8.2.80.0030.00518.03
8.2.70.0040.00417.38
8.2.60.0030.00917.93
8.2.50.0030.00518.07
8.2.40.0030.00618.28
8.2.30.0100.00018.21
8.2.20.0040.00417.85
8.2.10.0060.00317.65
8.2.00.0050.00317.76
8.1.280.0150.00025.92
8.1.270.0080.00021.79
8.1.260.0000.00726.35
8.1.250.0090.00028.09
8.1.240.0060.00324.00
8.1.230.0100.00319.14
8.1.220.0000.00817.77
8.1.210.0040.00418.77
8.1.200.0000.00817.36
8.1.190.0040.00417.52
8.1.180.0040.00418.10
8.1.170.0080.00018.59
8.1.160.0070.00022.09
8.1.150.0040.00418.68
8.1.140.0030.00517.51
8.1.130.0030.00317.76
8.1.120.0040.00417.36
8.1.110.0040.00417.54
8.1.100.0070.00017.47
8.1.90.0050.00217.47
8.1.80.0040.00417.40
8.1.70.0070.00017.49
8.1.60.0000.00817.57
8.1.50.0000.00717.57
8.1.40.0080.00017.55
8.1.30.0030.00517.66
8.1.20.0050.00317.54
8.1.10.0000.00817.61
8.1.00.0000.00717.49
8.0.300.0030.00318.77
8.0.290.0040.00417.05
8.0.280.0070.00018.47
8.0.270.0050.00317.28
8.0.260.0060.00016.87
8.0.250.0000.00616.99
8.0.240.0030.00316.93
8.0.230.0070.00016.84
8.0.220.0030.00316.75
8.0.210.0030.00316.84
8.0.200.0030.00316.91
8.0.190.0040.00417.04
8.0.180.0030.00316.89
8.0.170.0080.00016.99
8.0.160.0000.00816.88
8.0.150.0040.00416.79
8.0.140.0040.00416.93
8.0.130.0030.00313.35
8.0.120.0050.00316.88
8.0.110.0000.00816.89
8.0.100.0000.00816.91
8.0.90.0000.00716.96
8.0.80.0030.01316.80
8.0.70.0000.00716.72
8.0.60.0000.00716.82
8.0.50.0070.00016.90
8.0.30.0090.01117.25
8.0.20.0070.01217.40
8.0.10.0060.00316.99
8.0.00.0080.01316.70
7.4.330.0070.00015.15
7.4.320.0030.00316.45
7.4.300.0000.00716.60
7.4.290.0000.00816.52
7.4.280.0000.00716.61
7.4.270.0000.00716.67
7.4.260.0000.00716.60
7.4.250.0040.00416.47
7.4.240.0000.00716.55
7.4.230.0030.00316.60
7.4.220.0070.01016.55
7.4.210.0040.01116.68
7.4.200.0070.00016.69
7.4.190.0030.00316.71
7.4.160.0100.00716.52
7.4.150.0150.00317.40
7.4.140.0130.00617.86
7.4.130.0110.00616.53
7.4.120.0100.00716.51
7.4.110.0170.00016.73
7.4.100.0090.01516.46
7.4.90.0030.01416.51
7.4.80.0070.01119.39
7.4.70.0100.00716.55
7.4.60.0130.00416.51
7.4.50.0030.00616.24
7.4.40.0070.00722.77
7.4.30.0110.00616.34
7.4.00.0040.01414.80
7.3.330.0030.00313.32
7.3.320.0000.00513.36
7.3.310.0070.00016.41
7.3.300.0040.00416.37
7.3.290.0090.00616.39
7.3.280.0110.00416.43
7.3.270.0120.00417.40
7.3.260.0100.00716.51
7.3.250.0150.00616.38
7.3.240.0090.00916.61
7.3.230.0090.02416.39
7.3.210.0130.00316.44
7.3.200.0110.01219.39
7.3.190.0040.01816.34
7.3.180.0090.01316.25
7.3.170.0120.00416.47
7.3.160.0050.01116.38
7.3.120.0060.00914.99
7.2.330.0120.00616.77
7.2.320.0060.01216.47
7.2.310.0060.01116.43
7.2.300.0070.01116.52
7.2.290.0140.00416.46
7.2.60.0060.00817.06
7.2.00.0000.01119.55
7.1.200.0030.01015.93
7.1.100.0040.00718.43
7.1.70.0030.00617.01
7.1.60.0160.00919.82
7.1.50.0100.00717.03
7.1.00.0070.07322.43
7.0.200.0070.00416.75
7.0.140.0070.07321.97
7.0.60.0070.05019.92
7.0.50.0130.07317.86
7.0.40.0270.07020.25
7.0.30.0330.05020.23
7.0.20.0300.07020.06
7.0.10.0030.09020.10
7.0.00.0000.07720.16
5.6.280.0070.06720.87
5.6.210.0100.07720.66
5.6.200.0170.07318.22
5.6.190.0070.04720.62
5.6.180.0300.03720.50
5.6.170.0270.08020.54
5.6.160.0030.09320.50
5.6.150.0070.04018.25
5.6.140.0100.08018.23
5.6.130.0100.04318.14
5.6.120.0030.07320.84
5.6.110.0100.08321.00
5.6.100.0130.03021.00
5.6.90.0070.08321.03
5.6.80.0100.07720.39
5.5.350.0270.06720.40
5.5.340.0030.05017.98
5.5.330.0030.04720.13
5.5.320.0270.05020.42
5.5.310.0270.05720.35
5.5.300.0170.07718.08
5.5.290.0070.04717.93
5.5.280.0030.07320.66
5.5.270.0070.04720.78
5.5.260.0100.07020.80
5.5.250.0030.04320.46
5.5.240.0100.03320.13
5.4.450.0400.04319.17
5.4.440.0770.03319.46
5.4.430.0330.03719.45
5.4.420.0130.04719.27
5.4.410.1130.03019.36
5.4.400.1330.03719.09
5.4.390.0130.02719.04
5.4.380.0370.06718.73
5.4.370.0370.05018.70
5.4.360.0400.05318.66
5.4.350.0270.05318.63
5.4.340.0370.05718.57
5.4.320.0070.03412.51
5.4.310.0040.04012.51
5.4.300.0030.03912.51
5.4.290.0080.03412.51
5.4.280.0040.04812.41
5.4.270.0070.07718.70
5.4.260.0030.08018.91
5.4.250.0130.07318.60
5.4.240.0100.07318.91
5.4.230.0200.04718.94
5.4.220.0170.06318.97
5.4.210.0100.06318.85
5.4.200.0130.06018.75
5.4.190.0130.06018.75
5.4.180.0030.08018.91
5.4.170.0200.06018.93
5.4.160.0230.04318.73
5.4.150.0170.05018.84
5.4.140.0100.06716.48
5.4.130.0270.05316.64
5.4.120.0170.05016.39
5.4.110.0170.07016.60
5.4.100.0130.05316.34
5.4.90.0170.05316.47
5.4.80.0100.06016.36
5.4.70.0270.04316.41
5.4.60.0130.04716.46
5.4.50.0100.06716.49
5.4.40.0100.05016.62
5.4.30.0130.06016.27
5.4.20.0170.05016.42
5.4.10.0070.07016.32
5.4.00.0130.04716.00
5.3.290.0050.05012.80
5.3.280.0100.06714.70
5.3.270.0170.05014.63
5.3.260.0100.05714.61
5.3.250.0130.05014.80
5.3.240.0170.07014.71
5.3.230.0100.07314.45
5.3.220.0200.05314.66
5.3.210.0130.05314.59
5.3.200.0170.04014.65
5.3.190.0070.06714.74
5.3.180.0130.05014.75
5.3.170.0100.05014.41
5.3.160.0130.04714.66
5.3.150.0100.05314.66
5.3.140.0130.06014.55
5.3.130.0030.05714.79
5.3.120.0030.06314.47
5.3.110.0100.06314.53
5.3.100.0100.07014.27
5.3.90.0170.06314.02
5.3.80.0070.05314.10
5.3.70.0030.06314.11
5.3.60.0100.06014.23
5.3.50.0100.06713.95
5.3.40.0130.04313.81
5.3.30.0070.07013.91
5.3.20.0170.06013.93
5.3.10.0130.04313.64
5.3.00.0100.05713.63
5.2.170.0030.04311.32
5.2.160.0100.05711.23
5.2.150.0130.05311.26
5.2.140.0100.04711.14
5.2.130.0070.06011.19
5.2.120.0000.04711.12
5.2.110.0030.06011.20
5.2.100.0070.06311.08
5.2.90.0070.04711.18
5.2.80.0100.04711.07
5.2.70.0170.05311.19
5.2.60.0030.04711.04
5.2.50.0030.04310.99
5.2.40.0070.04711.10
5.2.30.0100.05710.95
5.2.20.0130.04710.94
5.2.10.0070.04710.77
5.2.00.0130.04310.96
5.1.60.0030.04310.10
5.1.50.0100.04310.11
5.1.40.0030.03710.19
5.1.30.0100.03710.34
5.1.20.0030.04310.27
5.1.10.0000.05710.05
5.1.00.0130.04010.32
5.0.50.0070.0308.56
5.0.40.0070.0338.38
5.0.30.0100.0378.28
5.0.20.0100.0308.16
5.0.10.0030.0308.25
5.0.00.0070.0378.02
4.4.90.0030.0236.06
4.4.80.0070.0176.06
4.4.70.0070.0176.06
4.4.60.0070.0206.06
4.4.50.0000.0336.06
4.4.40.0070.0436.06
4.4.30.0000.0276.06
4.4.20.0030.0206.06
4.4.10.0000.0306.06
4.4.00.0030.0336.06
4.3.110.0000.0276.06
4.3.100.0000.0336.06
4.3.90.0030.0206.06
4.3.80.0030.0336.06
4.3.70.0100.0176.06
4.3.60.0070.0206.06
4.3.50.0000.0236.06
4.3.40.0000.0476.06
4.3.30.0070.0206.06
4.3.20.0070.0206.06
4.3.10.0030.0236.06
4.3.00.0170.03715.58

preferences:
61.36 ms | 401 KiB | 5 Q