3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_valid_date($value, $format = 'dd.mm.yyyy'){ if(strlen($value) >= 6 && strlen($format) == 10){ // find separator. Remove all other characters from $format $separator_only = str_replace(array('m','d','y'),'', $format); $separator = $separator_only[0]; // separator is first character if($separator && strlen($separator_only) == 2){ // make regex $regexp = str_replace('mm', '(0?[1-9]|1[0-2])', $format); $regexp = str_replace('dd', '(0?[1-9]|[1-2][0-9]|3[0-1])', $regexp); $regexp = str_replace('yyyy', '((?:19|20)\d\d)', $regexp); $regexp = str_replace($separator, "\\" . $separator, $regexp); echo ($regexp."<br>\n"); if($regexp != $value && preg_match('/'.$regexp.'\z/', $value)){ // check date $arr=explode($separator,$value); $day=$arr[0]; $month=$arr[1]; $year=$arr[2]; if(@checkdate($month, $day, $year)) return true; } } } return false; } var_dump(is_valid_date('22.22.2222', 'mm.dd.yyyy')); // returns false var_dump(is_valid_date('11/30/2008', 'mm/dd/yyyy')); // returns true var_dump(is_valid_date('30-01-2008', 'dd-mm-yyyy')); // returns true var_dump(is_valid_date('2008 01 30', 'yyyy mm dd')); // returns true

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.40.0140.00719.22
8.3.30.0120.00319.09
8.3.20.0040.00420.16
8.3.10.0040.00422.10
8.3.00.0000.00722.44
8.2.170.0070.00722.96
8.2.160.0070.00720.53
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0040.00419.56
8.2.110.0090.00020.35
8.2.100.0040.00819.23
8.2.90.0040.00419.35
8.2.80.0000.00817.97
8.2.70.0030.00617.73
8.2.60.0080.00017.93
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0030.00518.23
8.2.20.0000.00817.92
8.2.10.0040.00417.99
8.2.00.0080.00017.88
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0000.00923.92
8.1.230.0110.00019.10
8.1.220.0000.00917.74
8.1.210.0040.00418.77
8.1.200.0030.00717.60
8.1.190.0000.00817.43
8.1.180.0050.00318.72
8.1.170.0000.00918.64
8.1.160.0040.00422.11
8.1.150.0000.00818.88
8.1.140.0000.00817.48
8.1.130.0000.00717.75
8.1.120.0000.00717.66
8.1.110.0030.00717.57
8.1.100.0040.00417.52
8.1.90.0030.00517.60
8.1.80.0020.00517.64
8.1.70.0000.00717.63
8.1.60.0040.00417.75
8.1.50.0000.00717.61
8.1.40.0040.00417.72
8.1.30.0030.00517.79
8.1.20.0060.00317.86
8.1.10.0040.00417.66
8.1.00.0040.00417.55
8.0.300.0030.00518.77
8.0.290.0030.00617.16
8.0.280.0040.00418.60
8.0.270.0040.00417.24
8.0.260.0030.00317.11
8.0.250.0000.00717.11
8.0.240.0000.00817.16
8.0.230.0040.00417.23
8.0.220.0050.00317.05
8.0.210.0040.00417.09
8.0.200.0040.00417.23
8.0.190.0040.00417.17
8.0.180.0040.00817.15
8.0.170.0030.00517.12
8.0.160.0000.00717.00
8.0.150.0050.00216.97
8.0.140.0000.00716.99
8.0.130.0060.00013.62
8.0.120.0030.00617.08
8.0.110.0000.00716.98
8.0.100.0000.00717.16
8.0.90.0030.00517.25
8.0.80.0060.01017.14
8.0.70.0040.00416.97
8.0.60.0040.00416.94
8.0.50.0050.00317.00
8.0.30.0100.01117.38
8.0.20.0100.01217.40
8.0.10.0030.00617.33
8.0.00.0150.00417.05
7.4.330.0060.00015.00
7.4.320.0000.00716.67
7.4.300.0070.00016.70
7.4.290.0000.00716.84
7.4.280.0070.00016.86
7.4.270.0030.00316.72
7.4.260.0000.00716.79
7.4.250.0050.00316.64
7.4.240.0030.00516.80
7.4.230.0040.00416.95
7.4.220.0060.01216.93
7.4.210.0070.01016.75
7.4.200.0050.00216.66
7.4.190.0000.00716.75
7.4.160.0100.00716.55
7.4.150.0140.00817.40
7.4.140.0080.01117.86
7.4.130.0120.00616.74
7.4.120.0110.00916.89
7.4.110.0130.00316.75
7.4.100.0030.01516.73
7.4.90.0090.00917.00
7.4.80.0090.02019.39
7.4.70.0100.00716.75
7.4.60.0100.00716.71
7.4.50.0050.00016.70
7.4.40.0150.00322.77
7.4.30.0160.01216.79
7.4.00.0040.01515.11
7.3.330.0050.00013.35
7.3.320.0030.00313.52
7.3.310.0040.00416.53
7.3.300.0070.00016.40
7.3.290.0120.00316.55
7.3.280.0080.00816.51
7.3.270.0030.01417.40
7.3.260.0160.00316.97
7.3.250.0060.01116.67
7.3.240.0060.01916.60
7.3.230.0120.00616.73
7.3.210.0070.01316.60
7.3.200.0190.00519.39
7.3.190.0150.00916.59
7.3.180.0030.01416.93
7.3.170.0100.00616.74
7.3.160.0170.00016.85
7.3.120.0090.00614.75
7.2.330.0080.00916.97
7.2.320.0170.00617.13
7.2.310.0080.01216.80
7.2.300.0100.00716.94
7.2.290.0030.01516.88
7.2.60.0060.00917.06
7.2.00.0000.01319.91
7.1.200.0090.00316.18
7.1.100.0000.01418.57
7.1.70.0050.00517.33
7.1.60.0100.01319.82
7.1.50.0030.01717.03
7.1.00.0000.03722.47
7.0.200.0120.00317.10
7.0.140.0070.07322.00
7.0.100.0370.06719.93
7.0.90.0370.07719.98
7.0.80.0330.06719.92
7.0.70.0270.07019.90
7.0.60.0270.08720.00
7.0.50.0330.08020.35
7.0.40.0070.05320.04
7.0.30.0130.08020.08
7.0.20.0070.08720.00
7.0.10.0170.07319.99
7.0.00.0100.07020.13
5.6.280.0000.07721.16
5.6.250.0170.06720.65
5.6.240.0200.06720.52
5.6.230.0100.07020.68
5.6.220.0030.07320.70
5.6.210.0130.06720.73
5.6.200.0030.09020.97
5.6.190.0100.08020.97
5.6.180.0100.07020.98
5.6.170.0070.08720.96
5.6.160.0000.08321.04
5.6.150.0070.04721.09
5.6.140.0170.06321.14
5.6.130.0130.08321.01
5.6.120.0000.07321.12
5.6.110.0000.08321.05
5.6.100.0070.07021.02
5.6.90.0030.08721.10
5.6.80.0000.04720.46
5.6.70.0100.07720.50
5.6.60.0070.04720.32
5.6.50.0130.07720.42
5.6.40.0070.08720.37
5.6.30.0170.06320.51
5.6.20.0030.08720.41
5.6.10.0070.06020.40
5.6.00.0100.07320.53
5.5.380.0170.06320.28
5.5.370.0070.04720.36
5.5.360.0100.08320.28
5.5.350.0030.08720.33
5.5.340.0130.07720.85
5.5.330.0030.05720.90
5.5.320.0100.06320.84
5.5.310.0170.07020.79
5.5.300.0200.06320.88
5.5.290.0070.08720.66
5.5.280.0070.06020.91
5.5.270.0070.04020.90
5.5.260.0100.07720.90
5.5.250.0130.07020.72
5.5.240.0000.08020.16
5.5.230.0030.08720.21
5.5.220.0170.07020.16
5.5.210.0100.07320.26
5.5.200.0100.07720.13
5.5.190.0000.08020.22
5.5.180.0100.08020.26
5.5.160.0030.09020.27
5.5.150.0030.07020.25
5.5.140.0030.08320.27
5.5.130.0100.04020.28
5.5.120.0100.04320.27
5.5.110.0170.07020.19
5.5.100.0170.06720.09
5.5.90.0030.04719.96
5.5.80.0030.04720.14
5.5.70.0030.08020.08
5.5.60.0100.07320.17
5.5.50.0030.08019.94
5.5.40.0030.08720.17
5.5.30.0130.04720.09
5.5.20.0070.08020.07
5.5.10.0100.07020.07
5.5.00.0270.06319.98
5.4.450.0030.05019.50
5.4.440.0100.07019.17
5.4.430.0030.04719.48
5.4.420.0030.08019.17
5.4.410.0000.08319.22
5.4.400.0070.06019.13
5.4.390.0100.07019.03
5.4.380.0130.06719.09
5.4.370.0070.07319.07
5.4.360.0100.07719.23
5.4.350.0100.04019.18
5.4.340.0070.04318.97
5.4.320.0130.06019.16
5.4.310.0030.05319.16
5.4.300.0100.07019.18
5.4.290.0100.03719.03
5.4.280.0000.08319.05
5.4.270.0100.07019.03
5.4.260.0000.08018.85
5.4.250.0030.06718.89
5.4.240.0100.06319.04
5.4.230.0130.06719.04
5.4.220.0170.05319.11
5.4.210.0170.07018.87
5.4.200.0130.05718.86
5.4.190.0100.07319.12
5.4.180.0070.04719.17
5.4.170.0070.07719.02
5.4.160.0070.05719.14
5.4.150.0000.08719.16
5.4.140.0070.07316.41
5.4.130.0030.04316.43
5.4.120.0000.08316.45
5.4.110.0070.07316.41
5.4.100.0170.03716.54
5.4.90.0070.07016.55
5.4.80.0070.07016.54
5.4.70.0070.07716.55
5.4.60.0100.07316.50
5.4.50.0100.07016.48
5.4.40.0100.06716.45
5.4.30.0070.06016.36
5.4.20.0100.05716.46
5.4.10.0130.06316.36
5.4.00.0170.03715.87
5.3.290.0070.07014.80
5.3.280.0070.08014.71
5.3.270.0100.07014.71
5.3.260.0030.08314.59
5.3.250.0100.07314.60
5.3.240.0070.07314.60
5.3.230.0070.07314.67
5.3.220.0100.05714.69
5.3.210.0100.07314.63
5.3.200.0000.05714.65
5.3.190.0070.07314.62
5.3.180.0030.08314.51
5.3.170.0030.08014.72
5.3.160.0100.07014.51
5.3.150.0030.07714.64
5.3.140.0070.07014.64
5.3.130.0000.08714.67
5.3.120.0070.07714.55
5.3.110.0100.07714.62
5.3.100.0030.08014.14
5.3.90.0030.07714.12
5.3.80.0100.07014.14
5.3.70.0170.06013.96
5.3.60.0130.07014.04
5.3.50.0100.07314.10
5.3.40.0070.07713.99
5.3.30.0000.08313.91
5.3.20.0130.06713.79
5.3.10.0030.07713.78
5.3.00.0030.07713.54
5.2.170.0070.06011.22
5.2.160.0070.06311.28
5.2.150.0070.06011.07
5.2.140.0030.07011.20
5.2.130.0100.05711.03
5.2.120.0130.05011.05
5.2.110.0030.05311.00
5.2.100.0130.05011.18
5.2.90.0070.05011.11
5.2.80.0070.06011.01
5.2.70.0070.05311.17
5.2.60.0070.05011.16
5.2.50.0070.06011.16
5.2.40.0030.03710.92
5.2.30.0030.04710.91
5.2.20.0070.05710.84
5.2.10.0100.05010.86
5.2.00.0030.06310.64
5.1.60.0000.04310.00
5.1.50.0030.0579.89
5.1.40.0130.0479.88
5.1.30.0100.05010.30
5.1.20.0070.05310.40
5.1.10.0070.05310.07
5.1.00.0030.05310.13
5.0.50.0030.0478.98
5.0.40.0030.0438.98
5.0.30.0070.0638.98
5.0.20.0030.0378.98
5.0.10.0000.0308.98
5.0.00.0030.0638.98
4.4.90.0000.0378.98
4.4.80.0070.0308.98
4.4.70.0030.0278.98
4.4.60.0070.0308.98
4.4.50.0000.0278.98
4.4.40.0070.0508.98
4.4.30.0000.0378.98
4.4.20.0000.0408.98
4.4.10.0000.0378.98
4.4.00.0030.0538.98
4.3.110.0030.0338.98
4.3.100.0070.0278.98
4.3.90.0030.0338.98
4.3.80.0030.0508.98
4.3.70.0030.0338.98
4.3.60.0000.0378.98
4.3.50.0030.0338.98
4.3.40.0000.0438.98
4.3.30.0000.0378.98
4.3.20.0030.0338.98
4.3.10.0070.0208.98
4.3.00.0070.0308.98

preferences:
30.69 ms | 400 KiB | 5 Q