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) & 0xff; $right = (ord($input[$i + $skip + 1]) & $mask) >> (8 - $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.0110.00418.18
8.3.50.0090.01121.96
8.3.40.0070.00718.85
8.3.30.0140.00019.04
8.3.20.0040.00420.29
8.3.10.0080.00021.96
8.3.00.0030.00522.48
8.2.180.0140.00716.63
8.2.170.0070.00722.96
8.2.160.0090.00619.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.0100.00022.09
8.2.100.0070.00417.91
8.2.90.0040.00419.17
8.2.80.0000.00817.97
8.2.70.0060.00317.50
8.2.60.0000.00918.04
8.2.50.0020.00718.07
8.2.40.0000.00818.34
8.2.30.0050.00518.13
8.2.20.0040.00417.64
8.2.10.0020.00517.76
8.2.00.0040.00417.87
8.1.280.0070.01025.92
8.1.270.0040.00421.95
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01223.96
8.1.230.0030.00719.22
8.1.220.0000.00817.76
8.1.210.0040.00418.77
8.1.200.0060.00317.23
8.1.190.0030.00517.53
8.1.180.0000.00918.10
8.1.170.0090.00018.59
8.1.160.0000.00721.88
8.1.150.0040.00418.55
8.1.140.0000.00717.49
8.1.130.0080.00017.84
8.1.120.0000.00717.38
8.1.110.0040.00417.37
8.1.100.0070.00017.36
8.1.90.0030.00317.32
8.1.80.0000.00717.43
8.1.70.0070.00017.42
8.1.60.0080.00017.55
8.1.50.0050.00317.55
8.1.40.0040.00417.55
8.1.30.0000.00817.71
8.1.20.0000.00717.67
8.1.10.0030.00517.59
8.1.00.0000.00817.43
8.0.300.0070.00018.77
8.0.290.0040.00417.15
8.0.280.0030.00518.50
8.0.270.0040.00417.27
8.0.260.0030.00316.79
8.0.250.0000.00716.90
8.0.240.0070.00016.98
8.0.230.0030.00316.94
8.0.220.0030.00316.81
8.0.210.0070.00016.89
8.0.200.0040.00416.86
8.0.190.0060.00316.83
8.0.180.0040.00416.91
8.0.170.0000.00716.91
8.0.160.0040.00416.98
8.0.150.0030.00316.84
8.0.140.0070.00016.88
8.0.130.0000.00513.33
8.0.120.0000.00816.79
8.0.110.0040.00416.94
8.0.100.0040.00416.82
8.0.90.0080.00016.91
8.0.80.0060.00916.79
8.0.70.0020.00516.94
8.0.60.0040.00416.93
8.0.50.0040.00416.75
8.0.30.0160.00517.12
8.0.20.0110.01017.40
8.0.10.0080.00016.88
8.0.00.0170.00516.82
7.4.330.0050.00215.00
7.4.320.0000.00616.53
7.4.300.0070.00016.55
7.4.290.0030.00316.36
7.4.280.0070.00016.53
7.4.270.0000.00716.38
7.4.260.0000.00716.59
7.4.250.0050.00216.42
7.4.240.0050.00316.51
7.4.230.0000.00716.59
7.4.220.0030.01616.63
7.4.210.0090.00916.50
7.4.200.0070.00016.36
7.4.190.0030.00316.40
7.4.160.0100.00716.34
7.4.150.0090.00817.40
7.4.140.0090.01017.86
7.4.130.0110.00916.51
7.4.120.0080.00816.63
7.4.110.0070.01716.39
7.4.100.0090.00916.33
7.4.90.0090.00916.37
7.4.80.0240.00019.39
7.4.70.0130.00316.51
7.4.60.0120.01216.44
7.4.50.0040.00416.46
7.4.40.0100.00322.77
7.4.30.0060.01116.36
7.4.00.0070.00715.16
7.3.330.0050.00013.16
7.3.320.0000.00513.15
7.3.310.0070.00016.33
7.3.300.0000.00716.33
7.3.290.0200.00016.42
7.3.280.0080.00716.40
7.3.270.0140.00317.40
7.3.260.0070.01116.76
7.3.250.0080.00916.64
7.3.240.0170.00016.61
7.3.230.0100.00616.48
7.3.210.0130.00316.58
7.3.200.0030.01519.39
7.3.190.0030.01416.36
7.3.180.0040.01116.50
7.3.170.0130.00316.52
7.3.160.0060.01316.34
7.3.120.0000.00914.64
7.2.330.0130.00616.56
7.2.320.0120.00816.73
7.2.310.0070.01416.79
7.2.300.0030.01316.54
7.2.290.0090.00816.70
7.2.110.0140.01416.61
7.2.60.0000.01617.09
7.2.00.0070.00719.54
7.1.200.0060.00715.85
7.1.100.0040.00817.86
7.1.70.0030.00717.16
7.1.60.0130.01019.82
7.1.50.0000.02216.90
7.1.00.0030.07722.31
7.0.200.0070.00716.74
7.0.140.0000.07722.00
7.0.60.0170.07020.02
7.0.50.0030.08717.88
7.0.40.0030.08720.26
7.0.30.0400.06320.26
7.0.20.0200.05720.21
7.0.10.0200.05320.23
7.0.00.0070.06020.25
5.6.280.0030.07321.09
5.6.210.0100.06320.73
5.6.200.0100.08318.25
5.6.190.0100.08720.46
5.6.180.3430.04320.33
5.6.170.0200.03720.57
5.6.160.0070.05720.71
5.6.150.0030.06718.19
5.6.140.0130.07318.24
5.6.130.0070.07018.18
5.6.120.0100.07320.95
5.6.110.0100.08021.10
5.6.100.0100.08020.98
5.6.90.0200.06321.00
5.6.80.0170.07020.39
5.6.70.0200.08020.47
5.5.350.0130.04320.44
5.5.340.0070.07718.09
5.5.330.0230.07020.19
5.5.320.0200.08720.34
5.5.310.0230.08720.46
5.5.300.0070.08318.07
5.5.290.0070.07717.95
5.5.280.0070.08720.88
5.5.270.0030.05020.85
5.5.260.0130.08320.88
5.5.250.0100.08320.70
5.5.240.0100.06720.28
5.4.450.0570.05719.55
5.4.440.0800.05019.16
5.4.430.0170.04719.63
5.4.420.0200.04719.54
5.4.410.0100.05719.42
5.4.400.0130.05018.62
5.4.390.0070.05318.57
5.4.380.0270.05318.76
5.4.370.0200.05018.62
5.4.360.0200.04718.58
5.4.350.0230.05018.73
5.4.340.0270.04718.75
5.4.320.0060.03712.52
5.4.310.0080.03512.51
5.4.300.0030.04512.51
5.4.290.0080.03812.51
5.4.280.0070.03612.41
5.4.270.0000.06018.91
5.4.260.0130.05018.93
5.4.250.0130.05718.90
5.4.240.0100.07318.71
5.4.230.0200.06718.69
5.4.220.0000.06318.93
5.4.210.0100.07318.88
5.4.200.0130.05018.94
5.4.190.0100.05018.88
5.4.180.0030.05719.04
5.4.170.0100.07718.88
5.4.160.0100.07018.70
5.4.150.0100.06718.91
5.4.140.0230.04016.38
5.4.130.0100.07316.54
5.4.120.0130.05016.39
5.4.110.0070.07016.63
5.4.100.0030.05316.40
5.4.90.0070.04716.46
5.4.80.0100.05016.40
5.4.70.0030.05316.58
5.4.60.0100.06716.39
5.4.50.0070.04716.54
5.4.40.0270.05316.45
5.4.30.0030.06716.50
5.4.20.0030.06016.37
5.4.10.0070.07716.47
5.4.00.0130.05315.71
5.3.290.0080.04012.80
5.3.280.0070.05314.60
5.3.270.0130.07314.68
5.3.260.0200.06314.80
5.3.250.0030.05314.59
5.3.240.0070.05014.85
5.3.230.0200.06714.75
5.3.220.0070.06014.57
5.3.210.0070.06014.59
5.3.200.0070.06014.65
5.3.190.0030.06314.77
5.3.180.0170.04314.56
5.3.170.0030.06714.48
5.3.160.0170.06314.67
5.3.150.0000.08014.58
5.3.140.0070.04714.58
5.3.130.0170.06314.65
5.3.120.0170.06714.46
5.3.110.0030.08314.65
5.3.100.0030.05314.02
5.3.90.0130.07014.11
5.3.80.0130.05014.09
5.3.70.0100.05713.93
5.3.60.0130.04313.84
5.3.50.0070.07013.79
5.3.40.0170.04313.79
5.3.30.0100.06314.00
5.3.20.0070.05713.54
5.3.10.0070.05713.72
5.3.00.0170.04313.64
5.2.170.0030.06011.11
5.2.160.0070.04011.16
5.2.150.0030.06011.07
5.2.140.0100.05711.24
5.2.130.0100.05311.12
5.2.120.0030.04311.09
5.2.110.0070.04011.12
5.2.100.0000.05311.33
5.2.90.0030.06011.02
5.2.80.0170.03711.01
5.2.70.0000.04711.06
5.2.60.0070.06011.29
5.2.50.0130.05011.26
5.2.40.0170.04710.84
5.2.30.0070.05011.07
5.2.20.0100.05010.80
5.2.10.0070.04310.96
5.2.00.0130.03310.90
5.1.60.0030.04010.07
5.1.50.0000.04310.07
5.1.40.0100.04310.04
5.1.30.0030.04010.34
5.1.20.0100.03710.20
5.1.10.0100.03310.15
5.1.00.0070.05010.09
5.0.50.0100.0308.90
5.0.40.0030.0338.90
5.0.30.0030.0578.90
5.0.20.0100.0238.90
5.0.10.0130.0238.90
5.0.00.0070.0438.90
4.4.90.0000.0238.90
4.4.80.0030.0238.90
4.4.70.0070.0278.90
4.4.60.0030.0278.90
4.4.50.0030.0238.90
4.4.40.0100.0378.90
4.4.30.0030.0208.90
4.4.20.0030.0278.90
4.4.10.0000.0278.90
4.4.00.0000.0378.90
4.3.110.0000.0338.90
4.3.100.0030.0208.90
4.3.90.0070.0208.90
4.3.80.0070.0308.90
4.3.70.0100.0178.90
4.3.60.0030.0208.90
4.3.50.0030.0208.90
4.3.40.0100.0308.90
4.3.30.0000.0238.90
4.3.20.0030.0238.90
4.3.10.0100.0138.90
4.3.00.0000.0237.38

preferences:
52.43 ms | 400 KiB | 5 Q