3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PasswordValidation { public static function digitCount($string) { return self::occurrencesCount($string, '/[0-9]/'); } public static function lcCount($string) { return self::occurrencesCount($string, '/[a-z]/'); } public static function ucCount($string) { return self::occurrencesCount($string, '/[A-Z]/'); } public static function nonAlphaNumCount($string) { return self::occurrencesCount($string, '/[^0-9a-zA-Z]/'); } 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; } private static function occurrencesCount($string, $regex) { preg_match_all($regex, $string, $matches); return count($matches[0]); } } $string = "abcdefg"; if (strlen($string) === PasswordValidation::consecutiveCharCount($string)) { echo "Password not allowed!"; }

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.0070.01516.88
8.3.60.0140.00718.30
8.3.50.0140.00622.01
8.3.40.0070.00718.68
8.3.30.0150.00419.21
8.3.20.0000.00920.16
8.3.10.0040.00423.51
8.3.00.0090.00019.69
8.2.180.0090.00916.50
8.2.170.0090.00622.96
8.2.160.0030.01720.24
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0100.00017.75
8.2.110.0090.00021.00
8.2.100.0040.00817.97
8.2.90.0040.00419.40
8.2.80.0080.00017.97
8.2.70.0080.00017.50
8.2.60.0030.00518.03
8.2.50.0080.00018.10
8.2.40.0040.00418.20
8.2.30.0040.00418.26
8.2.20.0050.00317.55
8.2.10.0040.00418.12
8.2.00.0000.00817.75
8.1.280.0060.00925.92
8.1.270.0040.00423.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.84
8.1.230.0070.00417.76
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0100.00017.23
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0060.00318.54
8.1.160.0030.00321.93
8.1.150.0050.00218.50
8.1.140.0070.00017.46
8.1.130.0000.00717.70
8.1.120.0000.00717.46
8.1.110.0110.00017.44
8.1.100.0040.00417.37
8.1.90.0070.00017.36
8.1.80.0040.00417.50
8.1.70.0040.00417.42
8.1.60.0080.00317.63
8.1.50.0030.00617.47
8.1.40.0030.00517.42
8.1.30.0060.00317.55
8.1.20.0060.00317.65
8.1.10.0000.00717.47
8.1.00.0040.00417.54
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0040.00418.44
8.0.270.0040.00417.13
8.0.260.0030.00317.21
8.0.250.0030.00316.86
8.0.240.0040.00416.86
8.0.230.0070.00016.83
8.0.220.0030.00316.82
8.0.210.0030.00316.80
8.0.200.0000.00916.84
8.0.190.0050.00316.77
8.0.180.0040.00416.87
8.0.170.0040.00416.90
8.0.160.0000.00716.93
8.0.150.0000.00716.77
8.0.140.0030.00316.71
8.0.130.0030.00313.21
8.0.120.0040.00416.75
8.0.110.0070.00016.77
8.0.100.0050.00216.76
8.0.90.0070.00016.87
8.0.80.0030.01316.73
8.0.70.0070.00016.72
8.0.60.0000.00916.92
8.0.50.0000.00716.85
8.0.30.0090.00917.03
8.0.20.0060.01317.40
8.0.10.0040.00416.85
8.0.00.0100.01016.88
7.4.330.0030.00315.15
7.4.320.0040.00416.61
7.4.300.0060.00016.52
7.4.290.0040.00416.50
7.4.280.0070.00016.61
7.4.270.0040.00416.51
7.4.260.0000.00816.58
7.4.250.0000.00716.42
7.4.240.0040.00416.54
7.4.230.0030.00316.59
7.4.220.0140.00316.40
7.4.210.0060.00916.47
7.4.200.0020.00516.70
7.4.160.0080.00816.66
7.4.150.0170.00017.40
7.4.140.0120.00417.86
7.4.130.0110.00716.51
7.4.120.0060.01116.43
7.4.110.0110.00716.63
7.4.100.0130.00616.38
7.4.90.0180.00016.59
7.4.80.0090.00919.39
7.4.70.0030.01616.46
7.4.60.0130.00316.41
7.4.50.0060.00316.27
7.4.40.0100.00716.26
7.4.30.0040.01216.48
7.4.00.0000.00814.80
7.3.330.0000.00513.30
7.3.320.0050.00013.18
7.3.310.0000.00716.39
7.3.300.0020.00516.34
7.3.290.0070.00716.29
7.3.280.0110.00916.37
7.3.270.0110.00717.40
7.3.260.0060.01516.36
7.3.250.0130.00616.55
7.3.240.0150.00616.61
7.3.230.0030.01316.39
7.3.210.0070.01016.29
7.3.200.0070.01019.39
7.3.190.0060.01116.45
7.3.180.0090.00616.29
7.3.170.0080.00816.49
7.3.160.0190.00416.35
7.3.120.0040.01114.74
7.3.10.0050.01216.54
7.3.00.0050.01416.70
7.2.330.0100.00716.89
7.2.320.0060.01216.66
7.2.310.0150.00316.80
7.2.300.0070.01716.80
7.2.290.0040.01216.43
7.2.130.0090.00916.95
7.2.120.0090.01016.92
7.2.110.0030.01116.86
7.2.100.0120.00416.91
7.2.90.0030.00916.99
7.2.80.0040.00916.97
7.2.70.0070.00716.89
7.2.60.0070.00616.85
7.2.50.0080.00516.79
7.2.40.0050.00917.02
7.2.30.0080.00816.90
7.2.20.0000.01416.85
7.2.10.0020.01716.81
7.2.00.0090.00417.75
7.1.250.0110.00615.67
7.1.100.0030.00618.18
7.1.70.0070.00717.02
7.1.60.0060.01819.70
7.1.50.0150.01116.99
7.1.00.0030.09022.51
7.0.200.0040.01216.83
7.0.140.0070.07022.05
7.0.60.0070.07019.99
7.0.50.0130.05017.92
7.0.40.0170.08020.11
7.0.30.0170.05320.25
7.0.20.0270.08720.24
7.0.10.0000.04720.22
7.0.00.0130.07720.18
5.6.280.0030.07321.04
5.6.210.0100.06020.52
5.6.200.0030.08018.14
5.6.190.0000.06320.61
5.6.180.4100.03320.43
5.6.170.0300.03720.64
5.6.160.0070.05020.61
5.6.150.0070.08318.27
5.6.140.0070.07318.24
5.6.130.0000.04318.13
5.6.120.0170.07721.02
5.6.110.0030.04321.16
5.6.100.0100.08021.13
5.6.90.0200.07320.99
5.6.80.0070.08020.52
5.6.70.1600.04320.44
5.5.350.0070.08320.43
5.5.340.0070.04018.00
5.5.330.0030.06320.45
5.5.320.0300.06320.24
5.5.310.0300.07720.51
5.5.300.0030.07718.07
5.5.290.0100.08718.07
5.5.280.0070.08720.97
5.5.270.0000.04720.98
5.5.260.0130.07320.81
5.5.250.0070.06320.56
5.5.240.0370.05320.28
5.4.450.0500.03343.86
5.4.440.0330.04343.79
5.4.430.0300.03743.77
5.4.420.0300.03743.77
5.4.410.0600.04743.77
5.4.400.0300.04043.76
5.4.390.0470.03743.73
5.4.380.0300.04718.69
5.4.370.0130.05718.75
5.4.360.0200.05018.54
5.4.350.0130.06018.73
5.4.340.0170.05718.63
5.4.320.0040.03712.51
5.4.310.0050.03812.51
5.4.300.0040.03912.52
5.4.290.0070.03912.51
5.4.280.0080.04012.41
5.4.270.0080.03512.41
5.4.260.0040.04112.41
5.4.250.0070.03912.41
5.4.240.0040.04312.41
5.4.230.0060.03912.40
5.4.220.0060.03712.40
5.4.210.0060.03712.40
5.4.200.0060.03812.40
5.4.190.0050.04012.40
5.4.180.0060.03612.40
5.4.170.0050.03812.41
5.4.160.0050.03712.41
5.4.150.0070.03412.41
5.4.140.0050.04012.08
5.4.130.0080.03412.07
5.4.120.0050.03612.03
5.4.110.0050.03712.03
5.4.100.0100.03412.02
5.4.90.0030.04412.02
5.4.80.0030.04212.03
5.4.70.0050.03712.03
5.4.60.0030.03812.02
5.4.50.0070.03912.02
5.4.40.0060.04412.01
5.4.30.0060.03612.01
5.4.20.0040.05312.01
5.4.10.0080.04712.01
5.4.00.0050.04711.50
5.3.290.0060.04812.80
5.3.280.0090.04012.71
5.3.270.0050.04112.72
5.3.260.0120.04312.72
5.3.250.0110.04812.72
5.3.240.0080.03512.72
5.3.230.0090.04712.71
5.3.220.0070.04012.68
5.3.210.0050.04112.68
5.3.200.0060.03712.68
5.3.190.0080.03712.68
5.3.180.0060.04012.67
5.3.170.0070.03612.67
5.3.160.0040.03812.68
5.3.150.0090.03612.68
5.3.140.0040.04512.66
5.3.130.0080.04312.66
5.3.120.0070.04712.66
5.3.110.0090.04612.66
5.3.100.0060.04112.13
5.3.90.0100.04112.12
5.3.80.0070.04212.11
5.3.70.0080.03712.11
5.3.60.0060.03912.10
5.3.50.0110.03712.04
5.3.40.0050.03612.04
5.3.30.0070.04712.00
5.3.20.0050.03911.78
5.3.10.0080.04011.75
5.3.00.0060.03611.73
5.2.170.0030.0329.25
5.2.160.0060.0299.25
5.2.150.0050.0379.24
5.2.140.0050.0309.24
5.2.130.0060.0409.20
5.2.120.0030.0319.20
5.2.110.0050.0379.21
5.2.100.0050.0329.20
5.2.90.0080.0399.20
5.2.80.0040.0319.19
5.2.70.0040.0319.20
5.2.60.0070.0289.15
5.2.50.0080.0279.12
5.2.40.0030.0309.09
5.2.30.0060.0299.07
5.2.20.0070.0439.05
5.2.10.0060.0268.96
5.2.00.0030.0308.82
5.1.60.0020.0258.11
5.1.50.0000.0298.11
5.1.40.0060.0228.09
5.1.30.0040.0268.43
5.1.20.0030.0288.46
5.1.10.0040.0258.18
5.1.00.0050.0258.19
5.0.50.0040.0206.67
5.0.40.0040.0186.54
5.0.30.0040.0306.35
5.0.20.0040.0186.31
5.0.10.0030.0246.30
5.0.00.0010.0346.29
4.4.90.0030.0194.78
4.4.80.0050.0164.76
4.4.70.0020.0184.75
4.4.60.0050.0144.76
4.4.50.0060.0194.77
4.4.40.0080.0204.71
4.4.30.0050.0134.76
4.4.20.0030.0154.85
4.4.10.0020.0164.85
4.4.00.0040.0294.76
4.3.110.0050.0184.67
4.3.100.0020.0164.66
4.3.90.0030.0154.64
4.3.80.0030.0254.58
4.3.70.0010.0174.63
4.3.60.0040.0144.62
4.3.50.0030.0244.63
4.3.40.0020.0324.54
4.3.30.0040.0153.30
4.3.20.0000.0183.28
4.3.10.0020.0173.24
4.3.00.0100.01337.49

preferences:
42.87 ms | 404 KiB | 6 Q