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 = "abcdegionoas"; if (strlen($string) === PasswordValidation::consecutiveCharCount($string)) { echo "Password not allowed!"; } echo PasswordValidation::consecutiveCharCount("abcdegionoas"); echo "\r\n"; echo PasswordValidation::consecutiveCharCount("EDCb00808asabc"); echo "\r\n"; echo PasswordValidation::consecutiveCharCount("asg7898"); echo "\r\n"; echo PasswordValidation::consecutiveCharCount("asgab876567asfon"); echo "\r\n"; echo PasswordValidation::repeatedCharCount("abcdegionoas"); echo "\r\n"; echo PasswordValidation::repeatedCharCount("EDCb00808asabc"); echo "\r\n"; echo PasswordValidation::repeatedCharCount("asg7898"); echo "\r\n"; echo PasswordValidation::repeatedCharCount("asgaaaCCc656bBBb7asfon"); echo "\r\n"; echo PasswordValidation::digitCount("asfA^as90Z8s%A8asB&f7sX/"); echo "\r\n"; echo PasswordValidation::lcCount("asfA^as90Z8s%A8asB&f7sX/"); echo "\r\n"; echo PasswordValidation::ucCount("asfA^as90Z8s%A8asB&f7sX/"); echo "\r\n"; echo PasswordValidation::nonAlphaNumCount("asfA^as90Z8s%A8asB&f7sX/"); echo "\r\n";

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.00716.59
8.3.50.0090.00722.11
8.3.40.0110.00419.04
8.3.30.0140.00719.10
8.3.20.0080.00020.34
8.3.10.0000.00923.59
8.3.00.0080.00019.81
8.2.180.0080.00816.63
8.2.170.0060.01222.96
8.2.160.0040.01120.43
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0110.00017.88
8.2.110.0060.00322.23
8.2.100.0040.00818.16
8.2.90.0040.00419.17
8.2.80.0090.00017.97
8.2.70.0030.00617.63
8.2.60.0030.00717.93
8.2.50.0030.00618.07
8.2.40.0030.00620.20
8.2.30.0040.00418.25
8.2.20.0000.00717.93
8.2.10.0030.00518.18
8.2.00.0040.00417.93
8.1.280.0090.00925.92
8.1.270.0090.00023.76
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0060.00323.88
8.1.230.0080.00318.98
8.1.220.0030.00517.79
8.1.210.0000.00818.77
8.1.200.0070.00317.60
8.1.190.0060.00317.48
8.1.180.0000.00818.10
8.1.170.0040.00418.70
8.1.160.0000.00822.08
8.1.150.0000.00718.77
8.1.140.0060.00317.60
8.1.130.0040.00417.94
8.1.120.0040.00417.63
8.1.110.0060.00317.65
8.1.100.0000.00717.48
8.1.90.0040.00417.49
8.1.80.0060.00317.55
8.1.70.0030.00517.60
8.1.60.0040.00817.68
8.1.50.0060.00317.67
8.1.40.0000.00817.70
8.1.30.0040.00417.74
8.1.20.0040.00417.69
8.1.10.0000.00717.67
8.1.00.0000.00817.76
8.0.300.0000.00718.77
8.0.290.0000.00817.00
8.0.280.0030.00518.41
8.0.270.0070.00017.32
8.0.260.0030.00317.29
8.0.250.0000.00717.05
8.0.240.0000.00817.11
8.0.230.0050.00217.05
8.0.220.0050.00316.98
8.0.210.0000.00817.02
8.0.200.0050.00216.95
8.0.190.0040.00417.13
8.0.180.0030.00617.15
8.0.170.0040.00417.17
8.0.160.0070.00017.12
8.0.150.0040.00417.08
8.0.140.0040.00417.04
8.0.130.0030.00313.41
8.0.120.0040.00417.00
8.0.110.0000.00717.05
8.0.100.0000.00717.11
8.0.90.0040.00416.97
8.0.80.0180.00417.11
8.0.70.0070.00017.17
8.0.60.0040.00417.09
8.0.50.0000.00716.96
8.0.30.0120.01117.14
8.0.20.0170.00717.40
8.0.10.0030.00517.01
8.0.00.0160.00517.16
7.4.330.0030.00315.16
7.4.320.0030.00616.87
7.4.300.0000.00716.74
7.4.290.0000.00716.82
7.4.280.0070.00016.79
7.4.270.0040.00416.87
7.4.260.0030.00316.80
7.4.250.0040.00416.69
7.4.240.0040.00416.77
7.4.230.0000.00716.92
7.4.220.0090.01016.78
7.4.210.0070.01016.71
7.4.200.0050.00316.85
7.4.160.0130.00316.61
7.4.150.0130.00417.40
7.4.140.0110.00617.86
7.4.130.0140.00716.76
7.4.120.0170.00216.81
7.4.110.0100.00716.71
7.4.100.0150.00316.59
7.4.90.0180.00016.71
7.4.80.0100.01319.39
7.4.70.0160.00016.61
7.4.60.0070.01016.64
7.4.50.0000.00916.73
7.4.40.0040.01416.67
7.4.30.0110.00616.73
7.4.00.0030.01315.14
7.3.330.0030.00313.55
7.3.320.0030.00313.40
7.3.310.0040.00416.39
7.3.300.0040.00416.55
7.3.290.0080.00616.59
7.3.280.0070.01216.54
7.3.270.0100.00717.40
7.3.260.0130.01116.89
7.3.250.0050.01516.60
7.3.240.0150.00316.61
7.3.230.0120.00616.65
7.3.210.0120.00916.83
7.3.200.0060.01219.39
7.3.190.0060.01116.91
7.3.180.0100.01016.59
7.3.170.0100.00716.91
7.3.160.0120.00916.89
7.3.120.0000.01415.11
7.2.330.0130.00617.08
7.2.320.0060.01217.02
7.2.310.0070.01617.09
7.2.300.0100.00716.96
7.2.290.0070.01616.86
7.2.00.0040.00819.83
7.1.100.0030.01018.23
7.1.70.0090.00617.45
7.1.60.0090.01619.70
7.1.50.0140.01117.16
7.1.00.0070.07322.35
7.0.200.0060.01217.02
7.0.140.0000.07722.15
7.0.60.0100.06720.17
7.0.50.0070.06717.94
7.0.40.0100.08720.30
7.0.30.0330.05020.22
7.0.20.0130.04320.08
7.0.10.0170.04720.22
7.0.00.0070.05320.25
5.6.280.0030.07321.16
5.6.210.0100.07020.54
5.6.200.0070.04318.22
5.6.190.0100.08020.34
5.6.180.0030.07020.46
5.6.170.0130.04320.51
5.6.160.0070.04320.50
5.6.150.0100.05718.21
5.6.140.0130.07018.21
5.6.130.0100.05318.18
5.6.120.0100.06020.93
5.6.110.0030.06721.03
5.6.100.0030.05321.04
5.6.90.0070.07321.13
5.6.80.0100.07320.38
5.6.70.0270.03320.44
5.5.350.0030.07720.52
5.5.340.0100.04317.96
5.5.330.0100.08320.32
5.5.320.0230.07720.42
5.5.310.0230.05320.30
5.5.300.0030.04018.08
5.5.290.0070.05717.99
5.5.280.0100.08320.93
5.5.270.0100.06720.79
5.5.260.0200.06720.82
5.5.250.0100.07320.74
5.5.240.0070.03320.32
5.4.450.0270.04743.86
5.4.440.0370.04743.79
5.4.430.0170.04743.77
5.4.420.0330.04043.77
5.4.410.0970.05043.77
5.4.400.0570.03343.76
5.4.390.0300.04043.73
5.4.380.0170.05718.64
5.4.370.0230.05018.52
5.4.360.0170.06318.78
5.4.350.0230.05018.50
5.4.340.0070.06018.70
5.4.320.0090.03312.53
5.4.310.0040.03912.52
5.4.300.0100.04512.53
5.4.290.0070.03812.52
5.4.280.0080.03512.42
5.4.270.0100.04912.42
5.4.260.0080.03612.42
5.4.250.0090.03612.42
5.4.240.0110.03912.42
5.4.230.0060.04112.41
5.4.220.0040.04012.41
5.4.210.0060.04912.42
5.4.200.0070.04412.42
5.4.190.0040.04112.41
5.4.180.0100.04212.41
5.4.170.0080.03412.42
5.4.160.0070.03912.42
5.4.150.0050.03912.41
5.4.140.0130.03612.10
5.4.130.0110.03312.08
5.4.120.0140.04212.05
5.4.110.0070.03512.04
5.4.100.0070.03412.04
5.4.90.0040.04612.04
5.4.80.0060.03912.04
5.4.70.0040.03712.04
5.4.60.0080.03912.04
5.4.50.0060.03612.04
5.4.40.0060.03512.03
5.4.30.0060.03612.02
5.4.20.0030.03812.02
5.4.10.0050.03512.02
5.4.00.0080.04111.51
5.3.290.0100.03712.80
5.3.280.0050.03812.71
5.3.270.0080.04812.72
5.3.260.0100.03512.72
5.3.250.0070.05212.72
5.3.240.0030.04812.71
5.3.230.0080.04112.71
5.3.220.0040.04112.68
5.3.210.0070.04212.68
5.3.200.0040.03912.68
5.3.190.0070.04812.68
5.3.180.0040.03912.68
5.3.170.0110.03912.68
5.3.160.0050.03812.68
5.3.150.0090.04012.68
5.3.140.0060.03712.66
5.3.130.0100.04512.66
5.3.120.0060.04012.66
5.3.110.0040.05112.66
5.3.100.0090.04012.15
5.3.90.0040.05012.13
5.3.80.0060.04212.12
5.3.70.0100.03612.12
5.3.60.0100.04112.11
5.3.50.0060.04212.05
5.3.40.0070.04112.05
5.3.30.0070.04012.02
5.3.20.0060.03811.80
5.3.10.0100.03111.76
5.3.00.0080.04711.75
5.2.170.0070.0359.25
5.2.160.0080.0269.25
5.2.150.0050.0339.25
5.2.140.0060.0339.25
5.2.130.0070.0319.21
5.2.120.0040.0339.21
5.2.110.0050.0349.22
5.2.100.0040.0309.21
5.2.90.0040.0309.22
5.2.80.0060.0309.21
5.2.70.0040.0329.21
5.2.60.0060.0309.17
5.2.50.0040.0319.13
5.2.40.0080.0299.12
5.2.30.0040.0319.09
5.2.20.0070.0339.08
5.2.10.0090.0348.98
5.2.00.0050.0308.84
5.1.60.0040.0248.13
5.1.50.0050.0308.12
5.1.40.0020.0398.11
5.1.30.0030.0288.46
5.1.20.0120.0258.48
5.1.10.0070.0298.20
5.1.00.0060.0248.20
5.0.50.0060.0246.70
5.0.40.0010.0296.55
5.0.30.0060.0466.37
5.0.20.0050.0186.33
5.0.10.0070.0176.31
5.0.00.0030.0316.30
4.4.90.0010.0174.78
4.4.80.0020.0204.75
4.4.70.0030.0154.75
4.4.60.0050.0204.75
4.4.50.0070.0234.77
4.4.40.0010.0274.71
4.4.30.0030.0154.76
4.4.20.0010.0184.84
4.4.10.0050.0144.85
4.4.00.0010.0274.76
4.3.110.0040.0144.67
4.3.100.0070.0114.67
4.3.90.0030.0144.63
4.3.80.0030.0354.58
4.3.70.0070.0194.63
4.3.60.0030.0144.63
4.3.50.0010.0184.63
4.3.40.0050.0224.54
4.3.30.0020.0163.30
4.3.20.0010.0173.29
4.3.10.0010.0173.24
4.3.00.0030.01737.49

preferences:
40.55 ms | 401 KiB | 5 Q