3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { public static function repeatedCharCount($string) { $lcString = strtolower($string); $prevChar = $lcString[0]; $currentLen = 0; $maxLen = 0; for ($i = 1; $i < strlen($lcString); $i++) { if ($lcString[$i] === $prevChar) { $currentLen += 1; } else { $currentLen = 1; } $maxLen = max($maxLen, $currentLen); $prevChar = $lcString[$i]; } return $maxLen; } public static function consecutiveCharCount($string) { $lcString = strtolower($string); $prevChar = $lcString[0]; $currentLen = 0; $maxLen = 0; $ascending = null; for ($i = 1; $i < strlen($lcString); $i++) { $diff = ord($lcString[$i]) - ord($prevChar); if ($diff == 1) { if ($ascending !== true) { $ascending = true; $currentLen = 1; } $currentLen += 1; } elseif ($diff == -1) { if ($ascending !== false) { $ascending = false; $currentLen = 1; } $currentLen += 1; } else { $currentLen = 1; } $maxLen = max($maxLen, $currentLen); $prevChar = $lcString[$i]; } return $maxLen; } } echo test::consecutiveCharCount("abcdegionoas"); echo test::consecutiveCharCount("EDCb00808asabc"); echo test::consecutiveCharCount("asg7898"); echo test::consecutiveCharCount("asgab876567asfon"); echo test::repeatedCharCount("abcdegionoas"); echo test::repeatedCharCount("EDCb00808asabc"); echo test::repeatedCharCount("asg7898"); echo test::repeatedCharCount("asgaaa656bbbb7asfon");

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.01116.63
8.3.50.0270.00322.11
8.3.40.0170.00018.69
8.3.30.0150.00619.17
8.3.20.0080.00019.95
8.3.10.0040.00423.61
8.3.00.0040.00419.68
8.2.180.0090.01216.75
8.2.170.0070.01418.79
8.2.160.0030.01022.96
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.01326.16
8.2.120.0070.00417.75
8.2.110.0070.00322.12
8.2.100.0040.00818.22
8.2.90.0000.00819.30
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0030.00617.93
8.2.50.0000.00918.07
8.2.40.0050.00319.82
8.2.30.0000.00718.26
8.2.20.0000.00817.79
8.2.10.0040.00418.05
8.2.00.0030.00517.77
8.1.280.0140.00025.92
8.1.270.0090.00023.85
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00723.93
8.1.230.0110.00019.00
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0060.00317.22
8.1.190.0080.00017.38
8.1.180.0050.00318.10
8.1.170.0030.00618.48
8.1.160.0000.00822.05
8.1.150.0000.00818.59
8.1.140.0000.00717.53
8.1.130.0000.00717.87
8.1.120.0050.00217.50
8.1.110.0030.00717.55
8.1.100.0000.00717.51
8.1.90.0070.00017.45
8.1.80.0050.00317.39
8.1.70.0030.00317.31
8.1.60.0050.00617.61
8.1.50.0030.00617.48
8.1.40.0040.00417.57
8.1.30.0030.00517.55
8.1.20.0060.00317.62
8.1.10.0040.00417.50
8.1.00.0040.00417.59
8.0.300.0000.00718.77
8.0.290.0000.00716.63
8.0.280.0000.00718.48
8.0.270.0050.00217.30
8.0.260.0070.00017.21
8.0.250.0030.00316.99
8.0.240.0030.00616.88
8.0.230.0000.00716.81
8.0.220.0080.00016.80
8.0.210.0030.00316.77
8.0.200.0000.00716.89
8.0.190.0050.00316.89
8.0.180.0000.00716.90
8.0.170.0050.00316.95
8.0.160.0030.00316.83
8.0.150.0060.00216.70
8.0.140.0000.00816.86
8.0.130.0050.00013.34
8.0.120.0050.00316.86
8.0.110.0070.00016.77
8.0.100.0040.00416.76
8.0.90.0040.00416.95
8.0.80.0130.01016.82
8.0.70.0040.00416.83
8.0.60.0040.00416.78
8.0.50.0000.00816.88
8.0.30.0140.00817.07
8.0.20.0120.00717.40
8.0.10.0080.00016.92
8.0.00.0100.00816.64
7.4.330.0000.00615.14
7.4.320.0060.00316.68
7.4.300.0060.00016.55
7.4.290.0030.00316.52
7.4.280.0000.00816.61
7.4.270.0070.00016.54
7.4.260.0000.00816.52
7.4.250.0040.00416.55
7.4.240.0020.00616.61
7.4.230.0000.00716.71
7.4.220.0070.01116.62
7.4.210.0150.00016.50
7.4.200.0000.00716.54
7.4.160.0080.00816.61
7.4.150.0060.01217.40
7.4.140.0110.00817.86
7.4.130.0120.00716.52
7.4.120.0090.01016.47
7.4.110.0100.00716.63
7.4.100.0120.00916.70
7.4.90.0070.01016.55
7.4.80.0160.00719.39
7.4.70.0080.00816.52
7.4.60.0070.01616.62
7.4.50.0090.00016.76
7.4.40.0070.01016.54
7.4.30.0090.00616.61
7.4.00.0070.01014.82
7.3.330.0000.00513.19
7.3.320.0050.00013.46
7.3.310.0030.00316.29
7.3.300.0030.00316.33
7.3.290.0100.00516.48
7.3.280.0060.01116.43
7.3.270.0040.01517.40
7.3.260.0130.01216.67
7.3.250.0090.01016.56
7.3.240.0060.01216.55
7.3.230.0150.00316.41
7.3.210.0130.00316.35
7.3.200.0040.01219.39
7.3.190.0130.00316.32
7.3.180.0140.00616.35
7.3.170.0160.00016.46
7.3.160.0070.01416.40
7.3.120.0110.00514.67
7.3.110.0070.01014.73
7.3.100.0060.00914.94
7.3.90.0030.01214.97
7.3.80.0030.01414.81
7.3.70.0040.00815.07
7.3.60.0070.01014.98
7.3.50.0060.00914.71
7.3.40.0060.00914.89
7.3.30.0060.00614.89
7.3.20.0130.00316.69
7.3.10.0080.00716.64
7.3.00.0090.00516.59
7.2.330.0140.00316.83
7.2.320.0070.01116.86
7.2.310.0140.00416.85
7.2.300.0130.00316.89
7.2.290.0070.01316.59
7.2.250.0030.01615.08
7.2.240.0100.01015.01
7.2.230.0060.00915.15
7.2.220.0030.01215.43
7.2.210.0070.01115.01
7.2.200.0040.01215.29
7.2.190.0040.01415.18
7.2.180.0160.00315.20
7.2.170.0030.01015.19
7.2.130.0000.01316.99
7.2.120.0060.00616.95
7.2.110.0030.00916.88
7.2.100.0070.00416.82
7.2.90.0000.00817.16
7.2.80.0070.00717.14
7.2.70.0000.01017.08
7.2.60.0050.00917.04
7.2.50.0110.00316.97
7.2.40.0090.00317.00
7.2.30.0040.01117.07
7.2.20.0000.01017.13
7.2.10.0060.00617.05
7.2.00.0030.00617.02
7.1.330.0000.01715.53
7.1.320.0110.00415.85
7.1.310.0030.01015.84
7.1.300.0110.00415.50
7.1.290.0060.00915.77
7.1.280.0060.00616.00
7.1.270.0030.01315.63
7.1.260.0090.00616.07
7.1.250.0000.00715.90
7.1.200.0060.00615.71
7.1.70.0070.00717.27
7.1.60.0100.01619.70
7.1.50.0070.01717.02
7.1.00.0000.07722.51
7.0.200.0070.01016.80
7.0.140.0130.06321.99
7.0.60.0100.06319.92
7.0.50.0070.08717.91
7.0.40.0170.07720.09
7.0.30.0230.04720.18
7.0.20.0200.07720.30
7.0.10.0030.04720.08
7.0.00.0030.08720.09
5.6.280.0000.07720.92
5.6.210.0130.06720.68
5.6.200.0170.05718.15
5.6.190.0100.08020.48
5.6.180.3770.04320.46
5.6.170.0230.06720.55
5.6.160.0070.08320.50
5.6.150.0000.04318.19
5.6.140.0070.07318.26
5.6.130.0070.04718.23
5.6.120.0130.07021.13
5.6.110.0070.07320.99
5.6.100.0070.04721.11
5.6.90.0070.09020.96
5.6.80.0170.07020.38
5.6.70.3570.03320.53
5.5.350.0030.04020.44
5.5.340.0100.03717.99
5.5.330.0130.05720.37
5.5.320.0230.05720.30
5.5.310.0130.08320.27
5.5.300.0070.03718.08
5.5.290.0130.07318.05
5.5.280.0070.05020.81
5.5.270.0030.05320.86
5.5.260.0100.08320.89
5.5.250.0000.04320.70
5.5.240.0330.06720.25
5.4.450.0200.03743.86
5.4.440.0170.05043.79
5.4.430.0170.04043.77
5.4.420.0330.04343.77
5.4.410.0300.04343.77
5.4.400.0470.04343.75
5.4.390.0400.04743.73
5.4.380.0200.05018.48
5.4.370.0230.05018.77
5.4.360.0200.05018.74
5.4.350.0230.04718.59
5.4.340.0270.04018.74
5.4.320.0100.03812.50
5.4.310.0050.03912.50
5.4.300.0090.03312.50
5.4.290.0020.04212.50
5.4.280.0060.03812.39
5.4.270.0060.03912.40
5.4.260.0110.03612.40
5.4.250.0070.03912.40
5.4.240.0060.03812.39
5.4.230.0080.03812.39
5.4.220.0040.03712.39
5.4.210.0070.03812.39
5.4.200.0070.03712.39
5.4.190.0060.03512.38
5.4.180.0060.04212.39
5.4.170.0040.03712.40
5.4.160.0040.04012.39
5.4.150.0080.04012.39
5.4.140.0070.04212.07
5.4.130.0070.03712.07
5.4.120.0090.03512.02
5.4.110.0090.03512.02
5.4.100.0060.03912.02
5.4.90.0060.03812.01
5.4.80.0070.03512.02
5.4.70.0070.04112.01
5.4.60.0080.03512.01
5.4.50.0070.03612.01
5.4.40.0090.03012.00
5.4.30.0080.04012.00
5.4.20.0110.03512.00
5.4.10.0060.03312.00
5.4.00.0060.03611.48
5.3.290.0050.03912.80
5.3.280.0090.03912.71
5.3.270.0050.04312.72
5.3.260.0070.05012.72
5.3.250.0050.04412.72
5.3.240.0080.03612.72
5.3.230.0070.03712.71
5.3.220.0070.03712.68
5.3.210.0080.04012.68
5.3.200.0050.03812.68
5.3.190.0060.03812.68
5.3.180.0050.03712.68
5.3.170.0030.04012.67
5.3.160.0080.04212.67
5.3.150.0050.03812.67
5.3.140.0060.03712.66
5.3.130.0110.03912.66
5.3.120.0050.04112.66
5.3.110.0070.03812.65
5.3.100.0040.04212.13
5.3.90.0090.03312.12
5.3.80.0040.03812.10
5.3.70.0080.03412.10
5.3.60.0080.03412.09
5.3.50.0070.04312.03
5.3.40.0060.04412.03
5.3.30.0060.04411.99
5.3.20.0070.03711.77
5.3.10.0060.03711.73
5.3.00.0040.03811.73
5.2.170.0080.0329.23
5.2.160.0050.0299.23
5.2.150.0020.0329.23
5.2.140.0050.0339.23
5.2.130.0060.0339.19
5.2.120.0050.0369.19
5.2.110.0070.0269.20
5.2.100.0050.0349.19
5.2.90.0040.0329.18
5.2.80.0080.0309.18
5.2.70.0030.0329.18
5.2.60.0080.0269.14
5.2.50.0050.0299.11
5.2.40.0040.0319.08
5.2.30.0070.0309.05
5.2.20.0040.0369.04
5.2.10.0050.0318.95
5.2.00.0030.0308.82
5.1.60.0080.0308.10
5.1.50.0080.0278.10
5.1.40.0050.0298.07
5.1.30.0030.0268.42
5.1.20.0050.0338.45
5.1.10.0040.0268.18
5.1.00.0030.0278.18
5.0.50.0040.0196.67
5.0.40.0070.0236.52
5.0.30.0050.0316.34
5.0.20.0030.0196.30
5.0.10.0060.0256.28
5.0.00.0060.0306.27
4.4.90.0030.0144.78
4.4.80.0020.0174.75
4.4.70.0010.0164.75
4.4.60.0020.0224.76
4.4.50.0040.0134.77
4.4.40.0020.0324.71
4.4.30.0060.0194.76
4.4.20.0040.0144.84
4.4.10.0040.0214.85
4.4.00.0030.0264.76
4.3.110.0020.0164.66
4.3.100.0020.0154.66
4.3.90.0030.0144.63
4.3.80.0050.0214.59
4.3.70.0040.0134.63
4.3.60.0060.0114.63
4.3.50.0020.0164.63
4.3.40.0020.0254.54
4.3.30.0020.0223.30
4.3.20.0030.0173.28
4.3.10.0010.0183.24
4.3.00.0030.01337.49

preferences:
49.43 ms | 401 KiB | 5 Q