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 = "gfedcba"; 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.60.0130.01018.25
8.3.50.0080.01021.98
8.3.40.0170.00018.73
8.3.30.0030.01019.25
8.3.20.0080.00020.11
8.3.10.0080.00023.66
8.3.00.0040.00419.81
8.2.180.0120.00316.60
8.2.170.0070.01122.96
8.2.160.0130.00720.27
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0130.00726.16
8.2.120.0040.00717.62
8.2.110.0060.00322.30
8.2.100.0060.00619.63
8.2.90.0030.00517.75
8.2.80.0040.00418.73
8.2.70.0040.00417.75
8.2.60.0060.00318.16
8.2.50.0040.00418.07
8.2.40.0000.00919.71
8.2.30.0000.00718.26
8.2.20.0050.00217.59
8.2.10.0050.00217.96
8.2.00.0040.00417.57
8.1.280.0070.01125.92
8.1.270.0040.00423.57
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00320.23
8.1.230.0070.00417.57
8.1.220.0030.00517.76
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0050.00317.35
8.1.180.0030.00618.10
8.1.170.0060.00618.52
8.1.160.0040.00421.93
8.1.150.0050.00218.63
8.1.140.0000.00817.45
8.1.130.0030.00317.73
8.1.120.0040.00417.35
8.1.110.0030.00617.36
8.1.100.0000.00717.52
8.1.90.0040.00417.49
8.1.80.0060.00317.37
8.1.70.0030.00317.43
8.1.60.0030.00517.56
8.1.50.0060.00317.44
8.1.40.0040.00417.58
8.1.30.0000.00817.66
8.1.20.0030.00617.50
8.1.10.0040.00417.59
8.1.00.0030.00617.49
8.0.300.0070.00018.77
8.0.290.0000.00816.63
8.0.280.0000.00718.40
8.0.270.0000.00717.16
8.0.260.0030.00317.25
8.0.250.0070.00016.91
8.0.240.0040.00416.79
8.0.230.0030.00316.95
8.0.220.0030.00316.86
8.0.210.0030.00316.76
8.0.200.0000.00716.78
8.0.190.0070.00016.88
8.0.180.0040.00416.75
8.0.170.0050.00216.91
8.0.160.0040.00416.73
8.0.150.0040.00416.85
8.0.140.0070.00016.79
8.0.130.0030.00313.22
8.0.120.0040.00416.77
8.0.110.0000.00716.75
8.0.100.0030.00516.87
8.0.90.0030.00316.79
8.0.80.0080.01416.84
8.0.70.0040.00416.85
8.0.60.0070.00016.84
8.0.50.0040.00416.95
8.0.30.0140.00516.95
8.0.20.0110.00917.40
8.0.10.0020.00516.83
8.0.00.0060.01216.69
7.4.330.0050.00015.12
7.4.320.0040.00416.66
7.4.300.0030.00316.52
7.4.290.0050.00216.59
7.4.280.0040.00416.46
7.4.270.0030.00316.50
7.4.260.0070.00016.39
7.4.250.0040.00416.54
7.4.240.0010.00616.61
7.4.230.0070.00016.34
7.4.220.0060.01516.64
7.4.210.0130.00716.54
7.4.200.0030.00316.71
7.4.160.0100.00716.54
7.4.150.0130.00617.40
7.4.140.0080.01417.86
7.4.130.0080.00816.51
7.4.120.0110.00516.53
7.4.110.0060.00916.32
7.4.100.0070.01116.58
7.4.90.0170.00316.58
7.4.80.0120.01219.39
7.4.70.0080.00816.45
7.4.60.0120.00616.62
7.4.50.0050.00516.42
7.4.40.0090.01016.47
7.4.30.0090.00616.68
7.4.10.0110.00715.13
7.4.00.0040.01214.84
7.3.330.0000.00513.24
7.3.320.0000.00513.32
7.3.310.0000.00616.19
7.3.300.0000.00716.22
7.3.290.0030.01016.29
7.3.280.0140.00516.31
7.3.270.0140.00417.40
7.3.260.0220.00316.33
7.3.250.0100.01016.47
7.3.240.0160.00616.57
7.3.230.0090.00916.39
7.3.210.0140.01016.60
7.3.200.0070.01416.38
7.3.190.0150.00616.35
7.3.180.0090.00916.56
7.3.170.0100.00716.67
7.3.160.0150.00616.36
7.3.130.0120.00614.92
7.3.120.0040.01214.89
7.3.110.0120.00615.07
7.3.100.0070.01014.66
7.3.90.0070.00714.99
7.3.80.0030.01414.87
7.3.70.0080.00314.80
7.3.60.0100.00514.89
7.3.50.0050.01014.86
7.3.40.0070.00414.93
7.3.30.0080.00514.92
7.3.20.0030.01116.61
7.3.10.0050.00916.70
7.3.00.0060.00616.85
7.2.330.0040.01516.86
7.2.320.0110.01216.74
7.2.310.0100.01016.91
7.2.300.0100.00616.73
7.2.290.0000.01716.82
7.2.260.0110.00714.86
7.2.250.0090.00615.25
7.2.240.0080.01015.06
7.2.230.0020.01215.29
7.2.220.0030.01415.16
7.2.210.0080.01015.31
7.2.200.0060.00315.09
7.2.190.0030.01215.00
7.2.180.0040.00915.12
7.2.170.0100.00715.21
7.2.160.0050.00915.06
7.2.150.0070.00516.79
7.2.140.0060.00817.00
7.2.130.0040.00616.92
7.2.120.0090.00816.85
7.2.110.0050.00816.78
7.2.100.0080.00716.94
7.2.90.0070.00916.94
7.2.80.0060.00616.95
7.2.70.0110.00517.05
7.2.60.0080.00617.03
7.2.50.0030.01316.92
7.2.40.0050.00816.97
7.2.30.0070.00817.00
7.2.20.0110.00517.03
7.2.10.0080.00716.90
7.2.00.0060.00817.46
7.1.330.0070.00915.95
7.1.320.0060.01015.70
7.1.310.0070.00615.79
7.1.300.0030.01115.58
7.1.290.0000.01115.76
7.1.280.0070.00815.69
7.1.270.0060.01015.96
7.1.260.0030.01215.86
7.1.250.0040.00815.74
7.1.240.0100.00515.83
7.1.230.0050.00915.73
7.1.220.0040.00615.79
7.1.210.0060.00815.77
7.1.200.0040.01115.71
7.1.190.0050.00815.86
7.1.180.0080.00715.96
7.1.170.0090.00415.88
7.1.160.0110.00415.83
7.1.150.0050.00815.80
7.1.140.0070.00815.84
7.1.130.0060.00715.87
7.1.120.0090.00415.92
7.1.110.0060.00615.89
7.1.100.0070.00716.35
7.1.90.0060.00715.77
7.1.80.0060.00715.83
7.1.70.0040.01016.05
7.1.60.0060.00916.63
7.1.50.0060.00816.08
7.1.40.0030.00915.80
7.1.30.0060.00815.81
7.1.20.0070.00515.88
7.1.10.0050.00815.76
7.1.00.0030.02517.08
7.0.330.0060.00615.46
7.0.320.0020.01015.45
7.0.310.0110.00115.40
7.0.300.0080.00815.30
7.0.290.0070.00615.27
7.0.280.0040.00915.41
7.0.270.0070.00615.37
7.0.260.0080.00515.31
7.0.250.0060.00815.44
7.0.240.0070.00615.52
7.0.230.0050.00815.46
7.0.220.0060.00915.36
7.0.210.0080.00415.34
7.0.200.0070.00715.74
7.0.190.0070.00615.39
7.0.180.0100.00315.45
7.0.170.0060.00415.50
7.0.160.0070.00715.39
7.0.150.0070.00815.28
7.0.140.0080.01816.70
7.0.130.0080.00715.28
7.0.120.0070.00615.43
7.0.110.0060.00915.54
7.0.100.0050.00815.40
7.0.90.0070.00815.40
7.0.80.0040.00915.43
7.0.70.0050.00715.46
7.0.60.0060.01716.33
7.0.50.0060.01515.95
7.0.40.0060.01914.83
7.0.30.0100.01514.73
7.0.20.0100.01714.79
7.0.10.0080.02014.79
7.0.00.0070.01514.73
5.6.400.0040.01114.49
5.6.390.0080.00814.66
5.6.380.0060.00814.38
5.6.370.0060.01114.59
5.6.360.0060.00714.42
5.6.350.0060.00814.56
5.6.340.0060.00814.41
5.6.330.0070.00714.33
5.6.320.0060.00814.30
5.6.310.0070.00614.47
5.6.300.0060.00714.19
5.6.290.0060.00614.38
5.6.280.0070.02115.80
5.6.270.0090.00514.51
5.6.260.0050.00814.57
5.6.250.0060.00614.37
5.6.240.0060.00614.43
5.6.230.0060.00714.37
5.6.220.0030.01014.40
5.6.210.0060.02115.73
5.6.200.0050.02215.27
5.6.190.0070.01415.67
5.6.180.0700.01415.60
5.6.170.0130.01115.73
5.6.160.0080.01215.55
5.6.150.0050.01515.29
5.6.140.0090.02115.21
5.6.130.0050.02015.19
5.6.120.0070.02115.78
5.6.110.0060.01315.72
5.6.100.0030.02315.71
5.6.90.0070.02115.71
5.6.80.0060.01515.66
5.6.70.0940.01415.45
5.6.60.0050.00814.40
5.6.50.0060.00814.39
5.6.40.0060.00714.38
5.6.30.0050.00714.32
5.6.20.0090.00514.32
5.6.10.0080.00614.48
5.6.00.0040.00814.23
5.5.380.0070.00512.92
5.5.370.0070.00312.90
5.5.360.0060.00712.78
5.5.350.0060.02014.48
5.5.340.0030.01413.88
5.5.330.0040.01614.37
5.5.320.0090.01914.45
5.5.310.0080.01614.34
5.5.300.0040.02313.90
5.5.290.0020.02213.83
5.5.280.0090.02314.44
5.5.270.0070.02214.56
5.5.260.0090.01814.53
5.5.250.0060.02214.41
5.5.240.0120.01914.32
5.5.230.0070.00612.79
5.5.220.0070.00612.78
5.5.210.0040.00712.75
5.5.200.0060.00612.80
5.5.190.0080.00312.76
5.5.180.0050.00912.86
5.5.170.0030.00813.55
5.5.160.0070.00612.71
5.5.150.0060.00512.75
5.5.140.0050.00712.74
5.5.130.0040.00812.83
5.5.120.0050.00712.83
5.5.110.0040.00712.85
5.5.100.0040.00712.88
5.5.90.0040.00612.81
5.5.80.0030.00912.83
5.5.70.0060.00712.74
5.5.60.0050.00612.74
5.5.50.0090.00312.74
5.5.40.0060.00712.83
5.5.30.0060.00612.78
5.5.20.0080.00412.71
5.5.10.0040.00612.80
5.5.00.0080.00412.55
5.4.450.0110.01317.81
5.4.440.0070.01417.76
5.4.430.0050.01417.70
5.4.420.0080.01417.76
5.4.410.0090.01317.76
5.4.400.0110.01317.74
5.4.390.0150.01517.71
5.4.380.0110.01212.69
5.4.370.0080.01512.64
5.4.360.0090.01412.74
5.4.350.0060.01712.71
5.4.340.0110.01412.71
5.4.330.0060.00511.25
5.4.320.0040.01311.49
5.4.310.0030.01311.46
5.4.300.0050.01211.44
5.4.290.0030.01411.51
5.4.280.0040.01211.45
5.4.270.0060.01111.46
5.4.260.0070.01011.46
5.4.250.0050.01111.54
5.4.240.0060.01011.45
5.4.230.0050.01011.41
5.4.220.0050.01311.50
5.4.210.0050.01111.43
5.4.200.0060.01211.46
5.4.190.0060.01011.40
5.4.180.0060.01111.40
5.4.170.0060.01211.43
5.4.160.0080.01011.43
5.4.150.0050.01511.45
5.4.140.0060.01211.36
5.4.130.0050.01211.38
5.4.120.0050.01211.33
5.4.110.0070.01111.34
5.4.100.0060.01011.43
5.4.90.0060.01111.40
5.4.80.0060.01111.32
5.4.70.0070.01311.41
5.4.60.0060.01311.41
5.4.50.0050.01111.43
5.4.40.0050.01211.40
5.4.30.0060.01011.40
5.4.20.0040.01511.41
5.4.10.0060.01111.44
5.4.00.0070.01111.27
5.3.290.0040.01411.47
5.3.280.0050.01111.43
5.3.270.0060.01411.40
5.3.260.0080.01211.43
5.3.250.0060.01411.44
5.3.240.0040.01211.41
5.3.230.0040.01411.37
5.3.220.0040.01211.34
5.3.210.0060.01211.42
5.3.200.0060.01111.40
5.3.190.0030.01411.37
5.3.180.0030.01411.43
5.3.170.0060.01011.44
5.3.160.0070.01111.44
5.3.150.0040.01311.45
5.3.140.0050.01311.35
5.3.130.0070.01411.40
5.3.120.0040.01211.43
5.3.110.0060.01111.40
5.3.100.0070.00911.26
5.3.90.0040.01211.31
5.3.80.0040.01211.29
5.3.70.0060.01011.28
5.3.60.0050.01211.30
5.3.50.0040.01111.29
5.3.40.0040.01211.22
5.3.30.0040.01211.25
5.3.20.0070.01111.18
5.3.10.0050.01311.18
5.3.00.0060.00911.15
5.2.170.0050.01310.56
5.2.160.0030.01610.56
5.2.150.0070.01110.56
5.2.140.0020.01610.56
5.2.130.0040.01510.55
5.2.120.0050.01310.55
5.2.110.0040.01310.55
5.2.100.0060.01210.55
5.2.90.0040.01410.55
5.2.80.0060.01310.54
5.2.70.0050.01410.54
5.2.60.0040.01510.53
5.2.50.0040.01610.52
5.2.40.0020.01310.51
5.2.30.0050.01510.50
5.2.20.0060.01310.50
5.2.10.0050.01310.47
5.2.00.0050.01210.42
5.1.60.0050.00910.18
5.1.50.0060.00810.18
5.1.40.0040.01310.18
5.1.30.0050.01010.29
5.1.20.0030.01210.30
5.1.10.0040.01010.21
5.1.00.0040.01210.21
5.0.50.0060.0089.71
5.0.40.0040.0119.66
5.0.30.0020.0149.60
5.0.20.0060.0119.59
5.0.10.0040.0089.58
5.0.00.0030.0139.58
4.4.90.0030.0089.07
4.4.80.0040.0089.06
4.4.70.0020.0079.07
4.4.60.0020.0109.07
4.4.50.0030.0129.07
4.4.40.0040.0139.05
4.4.30.0010.0109.07
4.4.20.0020.0109.09
4.4.10.0020.0109.10
4.4.00.0030.0109.07
4.3.110.0030.0079.04
4.3.100.0030.0069.04
4.3.90.0040.0079.03
4.3.80.0020.0109.01
4.3.70.0040.0069.02
4.3.60.0020.0089.02
4.3.50.0020.0079.02
4.3.40.0020.0128.99
4.3.30.0040.0068.58
4.3.20.0040.0068.58
4.3.10.0020.0098.56
4.3.00.0050.00419.98

preferences:
54.47 ms | 401 KiB | 5 Q