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) & 0xff; $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("%08b %08b\n", $left, $right); $output[$i] = chr(($left | $right) & 0xff); } } //0b000100010001000100000000; $input = "abc\x00"; $bits = 2; string_shift_left($input, strlen($input) - 1, $bits, $output); for ($i = 0; $i < strlen($input); $i++) { printf("\n%02x: %08b", ord($input[$i]), ord($input[$i])); } for ($i = 0; $i < strlen($output); $i++) { printf("\n%02x: %08b", ord($output[$i]), 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.0070.00718.30
8.3.50.0120.00521.95
8.3.40.0070.00718.85
8.3.30.0110.00419.06
8.3.20.0080.00020.38
8.3.10.0000.00822.05
8.3.00.0000.00822.57
8.2.180.0150.00616.50
8.2.170.0110.00422.96
8.2.160.0100.00719.20
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00417.50
8.2.110.0060.00321.93
8.2.100.0070.00419.34
8.2.90.0040.00419.30
8.2.80.0000.00918.04
8.2.70.0000.00817.63
8.2.60.0030.00617.93
8.2.50.0000.00818.07
8.2.40.0040.00418.22
8.2.30.0030.00718.05
8.2.20.0050.00317.67
8.2.10.0000.00817.87
8.2.00.0000.00817.63
8.1.280.0100.00725.92
8.1.270.0070.00022.05
8.1.260.0000.00726.35
8.1.250.0000.00728.09
8.1.240.0050.00523.59
8.1.230.0060.00619.14
8.1.220.0080.00017.74
8.1.210.0030.00518.77
8.1.200.0070.00317.25
8.1.190.0040.00417.52
8.1.180.0050.00318.10
8.1.170.0040.00418.63
8.1.160.0000.00722.02
8.1.150.0000.00718.63
8.1.140.0000.00717.37
8.1.130.0000.00717.92
8.1.120.0030.00517.36
8.1.110.0000.00817.40
8.1.100.0000.00717.51
8.1.90.0040.00417.45
8.1.80.0040.00417.46
8.1.70.0080.00017.49
8.1.60.0090.00017.58
8.1.50.0060.00317.43
8.1.40.0000.00817.51
8.1.30.0040.00417.62
8.1.20.0050.00317.59
8.1.10.0080.00017.57
8.1.00.0040.00417.51
8.0.300.0000.00718.77
8.0.290.0000.00817.16
8.0.280.0030.00318.45
8.0.270.0000.00717.33
8.0.260.0000.00716.82
8.0.250.0000.00816.84
8.0.240.0030.00317.03
8.0.230.0030.00317.00
8.0.220.0000.00716.95
8.0.210.0020.00516.96
8.0.200.0070.00016.89
8.0.190.0030.00316.96
8.0.180.0030.00316.96
8.0.170.0000.00816.93
8.0.160.0080.00016.78
8.0.150.0070.00016.76
8.0.140.0000.00816.90
8.0.130.0030.00313.26
8.0.120.0070.00016.86
8.0.110.0000.00816.92
8.0.100.0030.00516.96
8.0.90.0000.00716.86
8.0.80.0060.00916.95
8.0.70.0020.00516.79
8.0.60.0000.00816.87
8.0.50.0000.00816.77
8.0.30.0100.01017.25
8.0.20.0050.01317.40
8.0.10.0000.00817.04
8.0.00.0030.01416.80
7.4.330.0040.00415.00
7.4.320.0030.00316.51
7.4.300.0020.00516.63
7.4.290.0030.00316.51
7.4.280.0030.00516.57
7.4.270.0000.00716.52
7.4.260.0080.00016.59
7.4.250.0000.00716.62
7.4.240.0040.00416.50
7.4.230.0000.00716.51
7.4.220.0100.00716.48
7.4.210.0080.00916.56
7.4.200.0030.00316.72
7.4.190.0040.00416.56
7.4.160.0040.01216.56
7.4.150.0060.01617.40
7.4.140.0110.00917.86
7.4.130.0100.00716.56
7.4.120.0120.00916.50
7.4.110.0130.00316.49
7.4.100.0060.01716.48
7.4.90.0060.01216.39
7.4.80.0070.01019.39
7.4.70.0130.00316.47
7.4.60.0030.01316.67
7.4.50.0000.00816.45
7.4.40.0050.00622.77
7.4.30.0080.01116.58
7.4.10.0090.00916.55
7.4.00.0050.01115.59
7.3.330.0000.00613.35
7.3.320.0030.00313.41
7.3.310.0000.00716.46
7.3.300.0030.00316.43
7.3.290.0040.01116.36
7.3.280.0070.00916.39
7.3.270.0000.01717.40
7.3.260.0120.00616.37
7.3.250.0080.00816.41
7.3.240.0100.00716.53
7.3.230.0180.00316.67
7.3.210.0100.00716.37
7.3.200.0090.01319.39
7.3.190.0100.01016.50
7.3.180.0090.00616.30
7.3.170.0090.01216.48
7.3.160.0100.01016.47
7.3.130.0030.01416.34
7.3.120.0080.00615.71
7.3.110.0040.01416.54
7.3.100.0070.01016.37
7.3.90.0070.00316.54
7.3.80.0070.00716.38
7.3.70.0100.00316.42
7.3.60.0080.00316.48
7.3.50.0030.01216.20
7.3.40.0100.00316.48
7.3.30.0030.01216.43
7.3.20.0030.00718.19
7.3.10.0040.00717.38
7.3.00.0080.00917.24
7.2.330.0120.00616.47
7.2.320.0070.01516.63
7.2.310.0200.00316.40
7.2.300.0100.01216.56
7.2.290.0030.01816.88
7.2.260.0070.00716.88
7.2.250.0110.00716.72
7.2.240.0070.01116.61
7.2.230.0070.01116.49
7.2.220.0030.01316.46
7.2.210.0030.00716.57
7.2.200.0030.00716.77
7.2.190.0110.00716.57
7.2.180.0060.00716.69
7.2.170.0030.01116.58
7.2.160.0040.01116.56
7.2.150.0070.00718.55
7.2.140.0030.01318.50
7.2.130.0060.00717.68
7.2.120.0080.00817.69
7.2.110.0070.00717.48
7.2.100.0030.00817.57
7.2.90.0070.01017.49
7.2.80.0100.01017.65
7.2.70.0100.00817.59
7.2.60.0150.00217.60
7.2.50.0100.00517.77
7.2.40.0050.01117.48
7.2.30.0130.00317.80
7.2.20.0060.00617.53
7.2.10.0040.01117.47
7.2.00.0040.01118.26
7.1.330.0000.01517.46
7.1.320.0070.00717.57
7.1.310.0040.00817.43
7.1.300.0090.00617.48
7.1.290.0090.00617.30
7.1.280.0030.00717.47
7.1.270.0040.00717.25
7.1.260.0070.00717.38
7.1.250.0050.00916.48
7.1.240.0070.00717.38
7.1.230.0060.00917.41
7.1.220.0090.00317.32
7.1.210.0060.00617.30
7.1.200.0030.00617.42
7.1.190.0060.00917.33
7.1.180.0140.00317.33
7.1.170.0030.00817.34
7.1.160.0070.00717.39
7.1.150.0080.00617.23
7.1.140.0000.01417.23
7.1.130.0060.00917.42
7.1.120.0090.00617.30
7.1.110.0070.00417.53
7.1.100.0020.00917.89
7.1.90.0060.01017.39
7.1.80.0060.00917.38
7.1.70.0040.00717.15
7.1.60.0110.00818.54
7.1.50.0060.00817.26
7.1.40.0040.01217.61
7.1.30.0000.01117.53
7.1.20.0060.00317.35
7.1.10.0030.01017.30
7.1.00.0050.04219.92
7.0.330.0100.00317.00
7.0.320.0080.00617.00
7.0.310.0060.00617.02
7.0.300.0040.01116.94
7.0.290.0100.00316.96
7.0.280.0060.00917.14
7.0.270.0060.01017.00
7.0.260.0090.00617.06
7.0.250.0030.00917.03
7.0.240.0060.00817.03
7.0.230.0060.00617.11
7.0.220.0080.00317.06
7.0.210.0000.01517.13
7.0.200.0100.00316.92
7.0.190.0030.00617.22
7.0.180.0050.00516.95
7.0.170.0070.00717.03
7.0.160.0000.01417.15
7.0.150.0090.00317.19
7.0.140.0070.03619.51
7.0.130.0070.00717.02
7.0.120.0040.01116.86
7.0.110.0070.00717.04
7.0.100.0030.00917.17
7.0.90.0090.00317.10
7.0.80.0030.01017.02
7.0.70.0060.00616.96
7.0.60.0050.03218.49
7.0.50.0060.02417.51
7.0.40.0050.04717.50
7.0.30.0220.03917.59
7.0.20.0220.04217.64
7.0.10.0150.02217.56
7.0.00.0100.04217.56
5.6.400.0090.00916.12
5.6.390.0060.00915.80
5.6.380.0030.00916.14
5.6.370.0060.00916.14
5.6.360.0030.01016.18
5.6.350.0040.01116.32
5.6.340.0080.00616.45
5.6.330.0040.01115.99
5.6.320.0030.01016.06
5.6.310.0140.00415.99
5.6.300.0030.00716.10
5.6.290.0060.00915.78
5.6.280.0030.00715.84
5.6.270.0040.00815.75
5.6.260.0030.01016.08
5.6.250.0120.00615.89
5.6.240.0070.01116.18
5.6.230.0000.00915.98
5.6.220.0000.01215.93
5.6.210.0050.03818.22
5.6.200.0080.03517.15
5.6.190.0050.04318.50
5.6.180.1560.01818.28
5.6.170.0030.03118.19
5.6.160.0070.04418.49
5.6.150.0070.04217.16
5.6.140.0030.02817.05
5.6.130.0050.03117.03
5.6.120.0070.04118.66
5.6.110.0140.03818.50
5.6.100.0050.04218.45
5.6.90.0070.02418.54
5.6.80.0070.03918.10
5.6.70.0120.04318.07
5.6.60.0030.01315.95
5.6.50.0060.00915.93
5.6.40.0030.00915.84
5.6.30.0030.01016.10
5.6.20.0060.00916.10
5.6.10.0030.01015.83
5.6.00.0000.01115.87
5.5.380.0030.01115.89
5.5.370.0090.00315.70
5.5.360.0110.00416.14
5.5.350.0080.04218.28
5.5.340.0050.04317.07
5.5.330.0020.04918.05
5.5.320.0150.04518.24
5.5.310.0080.03518.11
5.5.300.0050.04116.95
5.5.290.0050.04517.07
5.5.280.0050.05018.44
5.5.270.0070.04018.47
5.5.260.0050.04518.45
5.5.250.0050.04518.24
5.5.240.0130.03617.96
5.5.230.0120.00315.99
5.5.220.0070.00715.99
5.5.210.0080.00415.82
5.5.200.0040.01215.98
5.5.190.0030.01215.90
5.5.180.0040.01515.89
5.5.170.0000.01115.95
5.5.160.0040.01215.93
5.5.150.0040.00715.67
5.5.140.0030.01415.91
5.5.130.0040.01115.85
5.5.120.0030.01016.03
5.5.110.0060.00315.96
5.5.100.0120.00816.07
5.5.90.0040.01115.74
5.5.80.0030.01015.81
5.5.70.0090.00615.89
5.5.60.0070.00715.86
5.5.50.0090.00615.87
5.5.40.0060.00915.96
5.5.30.0030.01315.80
5.5.20.0040.01215.85
5.5.10.0040.01415.94
5.5.00.0030.01215.96
5.4.450.0420.03116.17
5.4.440.0400.03016.10
5.4.430.0050.03216.22
5.4.420.0080.03116.23
5.4.410.0080.03016.17
5.4.400.0110.03615.63
5.4.390.0080.02815.83
5.4.380.0130.03415.62
5.4.370.0110.03015.76
5.4.360.0150.02315.77
5.4.350.0130.03015.76
5.4.340.0110.02815.69
5.4.330.0060.00312.75
5.4.320.0060.02612.62
5.4.310.0060.02412.71
5.4.300.0070.02312.69
5.4.290.0040.02712.64
5.4.280.0060.02212.62
5.4.270.0070.02915.84
5.4.260.0120.02715.85
5.4.250.0100.04315.84
5.4.240.0080.03415.81
5.4.230.0120.02515.89
5.4.220.0030.03515.83
5.4.210.0070.04315.86
5.4.200.0070.03215.71
5.4.190.0070.03315.72
5.4.180.0050.03115.88
5.4.170.0120.03615.86
5.4.160.0050.03815.86
5.4.150.0030.03515.95
5.4.140.0100.03514.68
5.4.130.0080.03214.65
5.4.120.0130.02514.59
5.4.110.0050.03014.63
5.4.100.0070.03814.62
5.4.90.0050.03414.67
5.4.80.0030.02914.60
5.4.70.0100.03514.77
5.4.60.0110.03014.55
5.4.50.0050.03914.66
5.4.40.0070.03014.54
5.4.30.0090.02814.60
5.4.20.0120.03214.56
5.4.10.0090.03914.58
5.4.00.0090.02414.39
5.3.290.0050.02712.96
5.3.280.0050.03213.95
5.3.270.0070.03413.87
5.3.260.0050.03213.87
5.3.250.0070.02813.83
5.3.240.0030.03213.90
5.3.230.0030.03213.84
5.3.220.0010.04713.80
5.3.210.0080.03913.83
5.3.200.0050.03313.74
5.3.190.0050.03313.94
5.3.180.0070.03713.79
5.3.170.0080.03813.83
5.3.160.0070.03913.97
5.3.150.0110.03113.84
5.3.140.0080.03513.94
5.3.130.0050.03213.98
5.3.120.0050.03514.02
5.3.110.0120.02813.84
5.3.100.0070.03713.62
5.3.90.0100.04013.56
5.3.80.0040.03913.45
5.3.70.0050.03013.67
5.3.60.0150.02813.55
5.3.50.0140.03213.43
5.3.40.0120.03213.50
5.3.30.0000.03213.63
5.3.20.0050.03213.34
5.3.10.0120.02513.27
5.3.00.0050.03513.14
5.2.170.0030.05011.23
5.2.160.0170.04711.24
5.2.150.0030.06311.14
5.2.140.0170.04011.23
5.2.130.0130.03711.10
5.2.120.0030.05011.18
5.2.110.0130.04011.20
5.2.100.0030.05311.20
5.2.90.0200.04311.12
5.2.80.0200.03311.19
5.2.70.0100.04311.32
5.2.60.0130.05311.07
5.2.50.0200.04711.20
5.2.40.0070.04311.00
5.2.30.0130.05011.10
5.2.20.0070.05310.94
5.2.10.0100.05310.86
5.2.00.0030.04310.71
5.1.60.0070.0439.93
5.1.50.0030.05010.10
5.1.40.0130.04010.06
5.1.30.0070.04310.35
5.1.20.0200.03710.43
5.1.10.0100.03310.14
5.1.00.0130.04310.32
5.0.50.0100.0308.73
5.0.40.0070.0378.68
5.0.30.0100.0508.31
5.0.20.0030.0378.20
5.0.10.0030.0438.36
5.0.00.0070.0578.44
4.4.90.0070.0236.86
4.4.80.0000.0336.86
4.4.70.0100.0176.86
4.4.60.0130.0206.86
4.4.50.0030.0276.86
4.4.40.0030.0376.86
4.4.30.0000.0336.86
4.4.20.0070.0276.86
4.4.10.0000.0336.86
4.4.00.0030.0406.86
4.3.110.0000.0236.86
4.3.100.0130.0206.86
4.3.90.0030.0236.86
4.3.80.0000.0476.86
4.3.70.0030.0306.86
4.3.60.0030.0276.86
4.3.50.0000.0236.86
4.3.40.0030.0436.86
4.3.30.0070.0206.86
4.3.20.0070.0276.86
4.3.10.0030.0306.86
4.3.00.0070.0237.38

preferences:
40.89 ms | 401 KiB | 5 Q