3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NIP { private const WEIGHTS = [6, 5, 7, 2, 3, 4, 5, 6, 7]; private const NIP_MODULO = 11; private const INVALID_CHECKSUM = 10; public static function validate(string $nip): bool { $value = preg_replace('/[\s-]/', '', $nip); if ('0000000000' === $value || !preg_match('/^\d{10}$/', $value)) { return false; } $checkSum = self::getChecksum($value); if (self::INVALID_CHECKSUM === $checkSum || $checkSum !== ((int) (substr($value, -1)))) { return false; } return true; } private static function getChecksum(string $nip): int { $sum = 0; foreach (self::WEIGHTS as $key => $weight) { $sum += $weight * ((int) $nip[$key]); } return $sum % self::NIP_MODULO; } } $nip_numbers = array( "1234563218", "9876543290", "5627384901", "9012345678", "6748392105", "4382905671", "7591234890", "8901234765", "3210987654", "9876504321" ); $c = new NIP(); foreach ($nip_numbers as $a) { var_dump($c->validate($a)); }

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.4.20.0110.01119.83
8.4.10.0080.00419.64
8.3.150.0090.00917.33
8.3.140.0000.00816.68
8.3.130.0080.00016.85
8.3.120.0290.01316.71
8.3.110.0370.00616.43
8.3.100.0370.01716.03
8.3.90.0410.00716.66
8.3.80.0440.00316.51
8.3.70.0300.00816.55
8.3.60.0180.00716.56
8.3.50.0280.01216.71
8.3.40.0280.01217.89
8.3.30.0190.00817.58
8.3.20.0330.00417.71
8.3.10.0270.00017.63
8.3.00.0090.00317.80
8.2.260.0080.00017.09
8.2.250.0060.00916.75
8.2.240.0250.00716.46
8.2.230.0260.01016.77
8.2.220.0270.00916.71
8.2.210.0230.01116.43
8.2.200.0210.01716.39
8.2.190.0330.00716.91
8.2.180.0230.01516.61
8.2.170.0370.00617.64
8.2.160.0240.02117.80
8.2.150.0270.01017.64
8.2.140.0320.00617.53
8.2.130.0350.00817.65
8.2.120.0260.01417.56
8.2.110.0390.00317.77
8.2.100.0300.01317.44
8.2.90.0370.00517.55
8.2.80.0300.01017.55
8.2.70.0360.00617.43
8.2.60.0400.00817.55
8.2.50.0270.01317.61
8.2.40.0250.01217.64
8.2.30.0210.01217.49
8.2.20.0360.00317.62
8.2.10.0420.00317.52
8.2.00.0230.01717.62
8.1.310.0030.00618.68
8.1.300.0280.00616.17
8.1.290.0270.00516.46
8.1.280.0290.00416.40
8.1.270.0370.01017.38
8.1.260.0290.01117.33
8.1.250.0320.00317.25
8.1.240.0320.00317.28
8.1.230.0170.00717.38
8.1.220.0240.00617.35
8.1.210.0260.00717.21
8.1.200.0250.00817.38
8.1.190.0170.00017.20
8.1.180.0380.00017.19
8.1.170.0310.00717.18
8.1.160.0340.00317.39
8.1.150.0280.00317.43
8.1.140.0310.00717.21
8.1.130.0240.01217.28
8.1.120.0360.00017.33
8.1.110.0290.00817.35
8.1.100.0260.01317.20
8.1.90.0290.01017.47
8.1.80.0280.00617.34
8.1.70.0300.00917.20
8.1.60.0180.02217.41
8.1.50.0370.00317.26
8.1.40.0380.00317.35
8.1.30.0370.00317.40
8.1.20.0310.00917.59
8.1.10.0320.00717.66
8.1.00.0320.00917.34

preferences:
34.73 ms | 403 KiB | 5 Q