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 = "123455"; 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.0100.01016.73
8.3.50.0140.00722.05
8.3.40.0140.00318.80
8.3.30.0130.00319.20
8.3.20.0050.00320.38
8.3.10.0070.00023.70
8.3.00.0040.00419.69
8.2.180.0090.00616.63
8.2.170.0070.00722.96
8.2.160.0130.00720.57
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00617.63
8.2.110.0000.01022.26
8.2.100.0110.00017.84
8.2.90.0040.00419.16
8.2.80.0000.00817.97
8.2.70.0030.00717.63
8.2.60.0060.00317.92
8.2.50.0040.00418.07
8.2.40.0000.00819.88
8.2.30.0030.00518.25
8.2.20.0040.00417.66
8.2.10.0050.00218.06
8.2.00.0000.00717.64
8.1.280.0100.01025.92
8.1.270.0040.00423.83
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0000.01024.02
8.1.230.0030.00719.16
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0060.00317.36
8.1.190.0050.00317.23
8.1.180.0060.00318.10
8.1.170.0000.00918.67
8.1.160.0040.00421.94
8.1.150.0070.00018.63
8.1.140.0000.00717.45
8.1.130.0050.00517.79
8.1.120.0040.00417.37
8.1.110.0030.00517.53
8.1.100.0030.00517.43
8.1.90.0040.00417.37
8.1.80.0070.00317.39
8.1.70.0000.00817.40
8.1.60.0050.00517.61
8.1.50.0050.00217.43
8.1.40.0090.00017.55
8.1.30.0040.00417.51
8.1.20.0000.00817.54
8.1.10.0050.00317.44
8.1.00.0000.00717.42
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0000.00718.35
8.0.270.0080.00017.20
8.0.260.0070.00017.11
8.0.250.0080.00016.90
8.0.240.0030.00616.79
8.0.230.0000.00716.88
8.0.220.0000.00716.83
8.0.210.0050.00216.82
8.0.200.0030.00316.91
8.0.190.0030.00516.89
8.0.180.0040.00416.77
8.0.170.0070.00016.84
8.0.160.0000.00716.66
8.0.150.0080.00416.65
8.0.140.0030.00616.65
8.0.130.0030.00313.32
8.0.120.0000.00816.82
8.0.110.0000.00816.86
8.0.100.0000.00716.80
8.0.90.0000.00816.79
8.0.80.0100.01016.76
8.0.70.0000.00716.82
8.0.60.0050.00316.70
8.0.50.0040.00416.83
8.0.30.0080.01117.08
8.0.20.0160.00317.40
8.0.10.0040.00416.90
8.0.00.0100.00816.73
7.4.330.0000.00615.00
7.4.320.0040.00416.59
7.4.300.0000.00716.39
7.4.290.0000.00716.65
7.4.280.0000.00716.35
7.4.270.0000.00716.60
7.4.260.0000.00716.58
7.4.250.0020.00516.45
7.4.240.0040.00416.56
7.4.230.0000.00716.59
7.4.220.0110.00716.56
7.4.210.0040.01016.38
7.4.200.0030.00416.35
7.4.160.0000.01616.54
7.4.150.0120.00617.40
7.4.140.0090.00817.86
7.4.130.0080.01016.48
7.4.120.0080.00816.38
7.4.110.0100.00716.49
7.4.100.0110.00716.41
7.4.90.0090.00916.41
7.4.80.0120.00619.39
7.4.70.0090.00616.56
7.4.60.0090.00616.49
7.4.50.0040.00416.59
7.4.40.0060.01416.48
7.4.30.0140.00216.51
7.4.00.0070.01014.93
7.3.330.0000.00513.33
7.3.320.0000.00513.32
7.3.310.0030.00316.41
7.3.300.0000.00716.29
7.3.290.0120.00616.37
7.3.280.0110.00516.36
7.3.270.0100.00717.40
7.3.260.0090.01216.38
7.3.250.0170.00016.41
7.3.240.0090.00916.39
7.3.230.0100.00616.52
7.3.210.0100.01016.38
7.3.200.0100.00619.39
7.3.190.0160.00016.50
7.3.180.0140.00816.68
7.3.170.0140.00416.57
7.3.160.0060.01016.30
7.3.120.0070.01014.90
7.3.110.0090.00614.80
7.3.100.0080.00814.93
7.3.90.0020.01315.07
7.3.80.0050.01015.02
7.3.70.0070.00415.03
7.3.60.0060.00714.98
7.3.50.0040.00714.87
7.3.40.0050.00814.95
7.3.30.0050.01214.81
7.3.20.0050.01016.71
7.3.10.0010.01116.62
7.3.00.0070.00516.52
7.2.330.0040.01416.52
7.2.320.0080.01116.71
7.2.310.0090.01016.79
7.2.300.0040.01516.50
7.2.290.0110.00716.55
7.2.250.0030.01814.83
7.2.240.0030.01315.06
7.2.230.0080.00914.88
7.2.220.0070.00715.11
7.2.210.0050.00915.20
7.2.200.0050.01115.26
7.2.190.0040.01215.29
7.2.180.0040.00915.11
7.2.170.0080.00815.15
7.2.160.0000.01415.20
7.2.150.0070.01016.98
7.2.140.0100.00316.76
7.2.130.0080.00416.89
7.2.120.0040.01117.11
7.2.110.0060.00616.79
7.2.100.0110.00316.99
7.2.90.0070.00316.89
7.2.80.0070.01016.94
7.2.70.0070.00717.01
7.2.60.0030.01317.00
7.2.50.0030.00617.13
7.2.40.0130.00016.85
7.2.30.0090.00316.86
7.2.20.0090.00416.96
7.2.10.0120.00317.01
7.2.00.0060.00918.23
7.1.330.0070.00715.67
7.1.320.0050.00816.00
7.1.310.0080.00715.84
7.1.300.0060.00515.76
7.1.290.0030.00915.65
7.1.280.0060.01115.68
7.1.270.0050.00815.55
7.1.260.0080.00615.88
7.1.250.0040.00815.76
7.1.100.0060.00918.17
7.1.70.0000.00817.07
7.1.60.0180.00719.70
7.1.50.0130.00616.84
7.1.00.0030.07722.32
7.0.200.0030.01316.81
7.0.140.0030.07321.99
7.0.60.0200.07020.08
7.0.50.0000.05017.91
7.0.40.0070.07319.96
7.0.30.0230.04320.17
7.0.20.0230.08020.30
7.0.10.0300.08020.21
7.0.00.0070.05020.07
5.6.280.0000.07721.04
5.6.210.0200.07720.66
5.6.200.0070.08018.29
5.6.190.0030.05320.40
5.6.180.0330.07020.64
5.6.170.0270.06720.50
5.6.160.0070.04020.43
5.6.150.0070.08018.18
5.6.140.0130.07018.17
5.6.130.0070.03718.28
5.6.120.0130.03021.14
5.6.110.0130.04021.03
5.6.100.0070.07720.99
5.6.90.0170.07021.00
5.6.80.0170.07320.44
5.6.70.3630.03720.39
5.5.350.0000.08720.47
5.5.340.0030.08317.95
5.5.330.0000.04320.29
5.5.320.0270.06720.29
5.5.310.0270.07320.32
5.5.300.0130.07717.98
5.5.290.0130.07317.96
5.5.280.0030.04020.98
5.5.270.0130.06720.78
5.5.260.0100.08020.86
5.5.250.0100.07720.79
5.5.240.0200.06720.20
5.4.450.0200.06719.55
5.4.440.0230.07319.46
5.4.430.0230.07719.52
5.4.420.0170.07319.46
5.4.410.0230.04319.08
5.4.400.0230.04719.21
5.4.390.0300.06019.16
5.4.380.0200.04018.89
5.4.370.0270.06319.31
5.4.360.0200.06319.14
5.4.350.0270.07018.99
5.4.340.0200.06019.31
5.4.320.0230.07319.22
5.4.310.0270.06718.99
5.4.300.0300.06318.99
5.4.290.0270.07019.06
5.4.280.0270.06719.15
5.4.270.0270.06719.09
5.4.260.0230.06318.95
5.4.250.0270.07319.15
5.4.240.0200.07018.86
5.4.230.0300.06318.99
5.4.220.0270.03319.21
5.4.210.0230.07319.13
5.4.200.0230.08019.08
5.4.190.0230.07019.07
5.4.180.0130.04018.97
5.4.170.0170.04019.15
5.4.160.0200.03319.14
5.4.150.0130.04018.93
5.4.140.0200.04016.36
5.4.130.0130.04316.50
5.4.120.0170.03316.33
5.4.110.0130.03716.54
5.4.100.0130.03316.35
5.4.90.0130.03716.29
5.4.80.0070.04016.49
5.4.70.0130.04016.57
5.4.60.0170.03016.53
5.4.50.0170.03316.56
5.4.40.0130.03716.50
5.4.30.0170.03316.34
5.4.20.0200.03316.25
5.4.10.0100.03716.33
5.4.00.0230.03015.91
5.3.290.0270.05714.61
5.3.280.0170.07314.83
5.3.270.0200.03314.54
5.3.260.0170.03714.63
5.3.250.0130.04014.53
5.3.240.0130.04314.54
5.3.230.0270.02314.48
5.3.220.0170.03314.57
5.3.210.0170.04014.71
5.3.200.0100.04014.59
5.3.190.0130.03714.58
5.3.180.0170.03314.63
5.3.170.0130.04014.74
5.3.160.0070.04314.48
5.3.150.0130.03714.59
5.3.140.0170.04014.48
5.3.130.0170.04014.55
5.3.120.0100.04714.49
5.3.110.0130.03714.48
5.3.100.0230.03313.98
5.3.90.0130.03714.05
5.3.80.0200.03713.95
5.3.70.0100.04014.04
5.3.60.0130.03714.03
5.3.50.0170.03313.88
5.3.40.0200.03014.08
5.3.30.0170.03013.83
5.3.20.0270.02713.80
5.3.10.0070.04013.90
5.3.00.0070.04713.58
5.2.170.0100.03312.68
5.2.160.0200.02012.68
5.2.150.0130.02712.68
5.2.140.0170.02312.68
5.2.130.0130.02712.68
5.2.120.0130.02312.68
5.2.110.0100.03312.68
5.2.100.0100.07012.68
5.2.90.0230.05312.68
5.2.80.0270.03312.68
5.2.70.0200.05312.68
5.2.60.0200.05712.68
5.2.50.0170.03012.68
5.2.40.0200.05312.68
5.2.30.0170.04012.68
5.2.20.0170.04712.68
5.2.10.0130.04312.68
5.2.00.0170.03712.68
5.1.60.0130.05012.68
5.1.50.0170.05012.68
5.1.40.0270.02712.68
5.1.30.0130.05312.68
5.1.20.0170.02712.68
5.1.10.0170.03012.68
5.1.00.0200.04712.68
5.0.50.0070.03012.68
5.0.40.0070.03012.68
5.0.30.0070.04712.68
5.0.20.0100.04012.68
5.0.10.0070.03312.68
5.0.00.0100.04012.68
4.4.90.0070.02012.68
4.4.80.0100.02312.68
4.4.70.0070.03712.68
4.4.60.0100.03312.68
4.4.50.0070.03312.68
4.4.40.0100.05012.68
4.4.30.0130.03312.68
4.4.20.0070.01712.68
4.4.10.0100.02012.68
4.4.00.0070.02712.68
4.3.110.0130.02312.68
4.3.100.0100.01712.68
4.3.90.0070.03712.68
4.3.80.0070.03712.68
4.3.70.0070.02012.68
4.3.60.0030.02312.68
4.3.50.0070.02312.68
4.3.40.0070.03712.68
4.3.30.0000.02312.68
4.3.20.0030.02312.68
4.3.10.0030.02712.68
4.3.00.0170.02312.68

preferences:
45.53 ms | 401 KiB | 5 Q