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]); } } 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.0090.00916.75
8.3.50.0110.00722.05
8.3.40.0070.01119.09
8.3.30.0090.00619.02
8.3.20.0040.00420.32
8.3.10.0080.00023.70
8.3.00.0040.00419.69
8.2.180.0110.01116.63
8.2.170.0140.00422.96
8.2.160.0100.01020.47
8.2.150.0090.00024.18
8.2.140.0150.00024.66
8.2.130.0070.00026.16
8.2.120.0060.00319.73
8.2.110.0030.00622.02
8.2.100.0030.00918.16
8.2.90.0030.00519.16
8.2.80.0000.00817.97
8.2.70.0040.00417.88
8.2.60.0060.00318.03
8.2.50.0030.00618.07
8.2.40.0000.00920.07
8.2.30.0040.00418.30
8.2.20.0000.00817.94
8.2.10.0000.00718.13
8.2.00.0030.00617.98
8.1.280.0140.00725.92
8.1.270.0060.00323.82
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0000.00923.74
8.1.230.0070.00419.12
8.1.220.0000.00817.91
8.1.210.0000.00818.77
8.1.200.0060.00317.38
8.1.190.0040.00417.47
8.1.180.0050.00318.10
8.1.170.0090.00018.86
8.1.160.0020.00521.99
8.1.150.0000.00718.73
8.1.140.0040.00417.57
8.1.130.0000.00717.89
8.1.120.0000.00717.56
8.1.110.0040.00717.66
8.1.100.0040.00417.55
8.1.90.0000.00717.71
8.1.80.0030.00617.63
8.1.70.0030.00517.58
8.1.60.0030.00617.68
8.1.50.0000.00817.74
8.1.40.0040.00417.70
8.1.30.0030.00617.75
8.1.20.0040.00417.81
8.1.10.0040.00417.66
8.1.00.0080.00017.75
8.0.300.0040.00418.77
8.0.290.0050.00216.88
8.0.280.0030.00518.45
8.0.270.0040.00417.30
8.0.260.0000.00617.30
8.0.250.0030.00417.11
8.0.240.0000.00917.13
8.0.230.0000.00717.06
8.0.220.0030.00316.95
8.0.210.0040.00416.88
8.0.200.0060.00017.09
8.0.190.0050.00217.17
8.0.180.0040.00416.98
8.0.170.0080.00017.08
8.0.160.0040.00317.02
8.0.150.0080.00017.09
8.0.140.0030.00517.00
8.0.130.0030.00313.52
8.0.120.0050.00317.13
8.0.110.0040.00416.98
8.0.100.0000.00717.10
8.0.90.0040.00417.07
8.0.80.0100.00616.99
8.0.70.0000.00716.95
8.0.60.0000.00717.01
8.0.50.0050.00216.89
8.0.30.0080.01117.34
8.0.20.0120.00917.40
8.0.10.0050.00217.21
8.0.00.0080.01017.01
7.4.330.0050.00015.17
7.4.320.0060.00316.77
7.4.300.0030.00316.74
7.4.290.0000.00716.87
7.4.280.0020.00516.75
7.4.270.0030.00316.88
7.4.260.0070.00016.83
7.4.250.0040.00416.73
7.4.240.0040.00316.80
7.4.230.0030.00316.95
7.4.220.0030.01716.76
7.4.210.0030.01216.88
7.4.200.0000.00716.95
7.4.160.0110.00716.47
7.4.150.0140.00417.40
7.4.140.0080.01117.86
7.4.130.0100.00716.84
7.4.120.0110.01116.65
7.4.110.0100.01316.82
7.4.100.0060.01116.84
7.4.90.0060.01116.74
7.4.80.0040.01619.39
7.4.70.0120.00416.71
7.4.60.0140.00416.73
7.4.50.0040.00416.86
7.4.40.0140.00316.75
7.4.30.0180.00316.71
7.4.00.0070.00615.24
7.3.330.0060.00013.54
7.3.320.0060.00013.52
7.3.310.0030.00416.55
7.3.300.0000.00716.53
7.3.290.0080.00716.54
7.3.280.0080.00916.50
7.3.270.0140.00617.40
7.3.260.0080.01916.52
7.3.250.0090.00916.64
7.3.240.0080.01616.56
7.3.230.0110.00716.55
7.3.210.0170.00016.78
7.3.200.0130.00319.39
7.3.190.0100.00716.79
7.3.180.0030.01516.55
7.3.170.0070.01316.70
7.3.160.0140.00316.75
7.3.120.0080.00514.98
7.3.110.0070.00715.29
7.3.100.0070.01015.05
7.3.90.0040.00415.02
7.3.80.0060.01315.40
7.3.70.0120.00614.99
7.3.60.0060.00615.03
7.3.50.0090.00314.95
7.3.40.0030.00514.94
7.3.30.0060.00915.05
7.3.20.0070.00716.91
7.3.10.0130.00316.61
7.3.00.0030.01016.95
7.2.330.0110.00716.71
7.2.320.0060.01217.09
7.2.310.0090.00916.98
7.2.300.0100.00716.82
7.2.290.0100.00716.84
7.2.250.0060.00915.32
7.2.240.0100.01015.23
7.2.230.0060.01015.31
7.2.220.0000.01115.21
7.2.210.0070.01115.09
7.2.200.0000.01315.28
7.2.190.0030.01015.42
7.2.180.0060.00815.00
7.2.170.0040.00415.28
7.2.160.0070.01115.37
7.2.150.0070.01116.97
7.2.140.0030.01316.86
7.2.130.0060.00616.99
7.2.120.0030.01317.24
7.2.110.0030.01217.18
7.2.100.0030.00717.11
7.2.90.0030.01317.25
7.2.80.0130.00316.95
7.2.70.0050.00517.04
7.2.60.0000.01117.16
7.2.50.0070.00716.98
7.2.40.0000.01616.87
7.2.30.0100.00317.16
7.2.20.0090.00317.12
7.2.10.0090.00917.15
7.2.00.0040.00718.29
7.1.330.0040.01115.80
7.1.320.0070.00715.89
7.1.310.0000.01116.12
7.1.300.0000.01715.81
7.1.290.0070.00715.89
7.1.280.0000.00916.09
7.1.270.0070.00715.98
7.1.260.0030.01015.73
7.1.250.0000.00816.04
7.1.240.0030.01015.91
7.1.230.0000.01515.69
7.1.220.0060.00316.14
7.1.210.0050.00416.15
7.1.200.0030.01015.87
7.1.190.0060.00616.06
7.1.180.0000.01415.75
7.1.170.0090.00616.01
7.1.160.0100.00316.06
7.1.150.0030.00715.78
7.1.140.0080.00315.89
7.1.130.0080.00816.11
7.1.120.0070.00715.92
7.1.110.0110.00415.97
7.1.100.0070.00617.12
7.1.90.0120.00316.05
7.1.80.0040.01115.75
7.1.70.0070.00616.65
7.1.60.0090.00917.79
7.1.50.0080.01116.54
7.1.40.0110.00316.03
7.1.30.0070.00316.02
7.1.20.0070.00715.76
7.1.10.0030.00715.68
7.1.00.0050.04219.18
7.0.330.0130.00315.48
7.0.320.0070.00315.59
7.0.310.0040.00915.26
7.0.300.0090.00015.71
7.0.290.0070.00715.66
7.0.280.0070.00415.48
7.0.270.0030.00615.55
7.0.260.0060.00615.48
7.0.250.0070.00415.69
7.0.240.0110.00415.48
7.0.230.0100.00715.68
7.0.220.0110.00315.68
7.0.210.0100.01015.70
7.0.200.0080.00616.22
7.0.190.0030.01115.49
7.0.180.0030.01415.63
7.0.170.0080.00815.69
7.0.160.0070.01015.70
7.0.150.0080.00415.71
7.0.140.0050.04018.87
7.0.130.0040.01115.45
7.0.120.0070.00715.41
7.0.110.0040.00815.73
7.0.100.0050.04717.83
7.0.90.0150.04317.86
7.0.80.0070.04217.68
7.0.70.0070.02518.04
7.0.60.0030.02617.72
7.0.50.0030.04618.04
7.0.40.0040.04516.85
7.0.30.0030.04816.98
7.0.20.0070.02716.85
7.0.10.0070.04016.82
7.0.00.0130.03716.75
5.6.400.0040.01414.25
5.6.390.0060.01014.91
5.6.380.0060.00914.42
5.6.370.0030.01014.29
5.6.360.0070.00714.38
5.6.350.0100.00314.84
5.6.340.0030.01014.59
5.6.330.0100.00314.73
5.6.320.0110.00414.11
5.6.310.0070.00714.68
5.6.300.0030.01414.59
5.6.290.0040.01114.38
5.6.280.0050.04217.89
5.6.270.0090.00614.38
5.6.260.0040.01114.84
5.6.250.0030.02717.54
5.6.240.0020.05117.61
5.6.230.0050.04017.79
5.6.220.0060.04317.51
5.6.210.0050.02717.55
5.6.200.0080.04017.80
5.6.190.0020.05017.72
5.6.180.0020.04617.70
5.6.170.0070.02617.79
5.6.160.0020.04717.84
5.6.150.0070.02817.85
5.6.140.0070.04717.99
5.6.130.0030.03317.86
5.6.120.0050.04717.84
5.6.110.0080.03317.82
5.6.100.0020.05017.86
5.6.90.0130.04217.73
5.6.80.0060.03017.58
5.6.70.0050.03317.38
5.6.60.0070.02417.62
5.6.50.0050.02417.45
5.6.40.0030.03117.36
5.6.30.0030.04217.40
5.6.20.0070.03717.50
5.6.10.0000.02817.41
5.6.00.0030.02617.35
5.5.380.0080.04017.36
5.5.370.0050.04017.43
5.5.360.0030.04117.54
5.5.350.0070.02717.44
5.5.340.0030.04517.71
5.5.330.0050.04417.67
5.5.320.0030.03117.55
5.5.310.0030.04017.62
5.5.300.0080.04317.49
5.5.290.0100.04317.70
5.5.280.0070.04217.65
5.5.270.0020.04817.69
5.5.260.0100.03317.77
5.5.250.0070.04217.44
5.5.240.0080.02117.41
5.5.230.0110.01617.30
5.5.220.0030.02617.43
5.5.210.0060.02017.14
5.5.200.0050.02417.22
5.5.190.0020.03017.29
5.5.180.0030.02617.21
5.5.170.0000.01614.28
5.5.160.0060.02417.19
5.5.150.0070.02117.43
5.5.140.0050.02217.32
5.5.130.0070.04117.23
5.5.120.0020.02717.36
5.5.110.0080.02117.25
5.5.100.0050.02317.24
5.5.90.0040.02517.25
5.5.80.0060.01817.22
5.5.70.0030.02417.24
5.5.60.0050.02217.24
5.5.50.0060.02217.30
5.5.40.0020.02617.24
5.5.30.0000.02517.12
5.5.20.0030.02516.99
5.5.10.0050.02317.25
5.5.00.0050.02217.21
5.4.450.0070.04015.52
5.4.440.0090.04115.32
5.4.430.0050.04015.19
5.4.420.0100.04215.49
5.4.410.0040.04215.13
5.4.400.0020.02715.19
5.4.390.0030.02215.22
5.4.380.0020.02515.27
5.4.370.0020.02515.12
5.4.360.0080.01815.26
5.4.350.0030.02915.07
5.4.340.0040.02415.17
5.4.330.0040.00411.45
5.4.320.0040.02215.07
5.4.310.0040.02115.21
5.4.300.0030.02115.19
5.4.290.0050.01915.08
5.4.280.0050.02815.17
5.4.270.0070.02015.29
5.4.260.0050.02015.25
5.4.250.0020.02215.16
5.4.240.0050.01815.05
5.4.230.0040.02015.21
5.4.220.0020.02215.24
5.4.210.0000.02515.18
5.4.200.0030.01915.21
5.4.190.0020.02315.18
5.4.180.0060.01815.22
5.4.170.0060.02115.02
5.4.160.0040.02015.11
5.4.150.0090.01915.16
5.4.140.0030.02013.88
5.4.130.0000.03313.97
5.4.120.0090.01513.83
5.4.110.0020.02113.85
5.4.100.0070.03613.80
5.4.90.0030.04113.90
5.4.80.0090.03413.80
5.4.70.0070.03413.95
5.4.60.0050.04113.90
5.4.50.0080.03613.79
5.4.40.0020.02413.80
5.4.30.0020.02413.85
5.4.20.0020.04113.91
5.4.10.0040.04013.83
5.4.00.0110.03513.59
5.3.290.0030.02113.00
5.3.280.0050.01912.94
5.3.270.0020.02612.95
5.3.260.0050.03412.88
5.3.250.0020.02312.88
5.3.240.0050.02012.95
5.3.230.0040.03012.89
5.3.220.0020.02212.87
5.3.210.0070.04012.87
5.3.200.0050.03712.91
5.3.190.0050.04212.92
5.3.180.0100.03212.95
5.3.170.0030.03912.94
5.3.160.0050.03912.93
5.3.150.0030.03912.87
5.3.140.0030.02712.95
5.3.130.0030.04112.85
5.3.120.0070.03512.88
5.3.110.0060.03112.85
5.3.100.0050.04112.64
5.3.90.0070.04012.59
5.3.80.0110.03212.65
5.3.70.0100.03212.65
5.3.60.0020.02212.66
5.3.50.0040.03512.65
5.3.40.0050.04012.54
5.3.30.0080.04012.60
5.3.20.0050.03612.45
5.3.10.0050.03712.40
5.3.00.0050.03512.51
5.2.170.0030.06311.11
5.2.160.0030.03311.17
5.2.150.0030.06011.27
5.2.140.0070.03311.32
5.2.130.0000.06711.00
5.2.120.0070.05711.20
5.2.110.0070.05711.07
5.2.100.0070.06311.23
5.2.90.0030.03311.25
5.2.80.0100.05711.02
5.2.70.0100.05711.16
5.2.60.0170.05311.11
5.2.50.0000.03711.04
5.2.40.0100.04711.10
5.2.30.0030.03711.12
5.2.20.0030.06011.06
5.2.10.0070.04310.97
5.2.00.0030.04310.89
5.1.60.0100.0439.92
5.1.50.0000.0379.92
5.1.40.0030.04710.09
5.1.30.0000.04310.39
5.1.20.0100.05010.31
5.1.10.0070.0509.96
5.1.00.0070.04310.20
5.0.50.0030.0178.48
5.0.40.0030.0438.57
5.0.30.0030.0608.37
5.0.20.0070.0378.34
5.0.10.0000.0478.34
5.0.00.0030.0508.34
4.4.90.0070.0278.34
4.4.80.0000.0308.34
4.4.70.0030.0238.34
4.4.60.0030.0308.34
4.4.50.0000.0378.34
4.4.40.0030.0408.34
4.4.30.0000.0338.34
4.4.20.0000.0308.34
4.4.10.0070.0238.34
4.4.00.0000.0438.34
4.3.110.0030.0308.34
4.3.100.0100.0238.34
4.3.90.0030.0338.34
4.3.80.0030.0578.34
4.3.70.0070.0308.34
4.3.60.0000.0378.34
4.3.50.0030.0308.34
4.3.40.0070.0378.34
4.3.30.0000.0278.34
4.3.20.0030.0238.34
4.3.10.0030.0238.34
4.3.00.0000.0238.34

preferences:
48.31 ms | 401 KiB | 5 Q