3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ 'bar 3 m foo', # - 'bass drop 2 d bare', # - '2 3 m foo foo', # - '1 222 4 d baz', # - '5d 4h 3m 2s', # - '5 days 4 minutes', # - '9w8d7h6m5s', # - '2 d 3 m baz', # + '5d 4h 3m 2s foo', # + '2 s foo', # + '222 h baz bar', # + '1 mon foo', # + mon for month? '1w bar', # + '1 month baz', # + '2 months foobar', # + '4 months 2 months foo', # + repeating same string is allowed by strtotime, though it sums up https://3v4l.org/FIgNC '5m3s bar', # + '7mon6w5d4h3m2s bazinga!', # + '3 seconds 5 hours 5 minutes jeeey hoe :D damn I should sleep...' # + ]; /* * Replaces (s|m|h|d|w|mon) with strtotime compatible abbreviations and return it in an array with the remaining text * * It *should* allow these: https://gist.github.com/DaveRandom/625fb4bf73112474fb5768a0a300e4e5 * * @param array $tests * @return array */ function separateAndNormalizeTimeSpec($tests) { $reg1 = <<<'REGEX' ~ \s? (?<int> \d{1,5}) \s? (?<time> (?: s (?=(?:ec(?:ond)?s?)?(?:\b|\d)) | m (?=(?:in(?:ute)?s?)?(?:\b|\d)) | h (?=(?:(?:ou)?rs?)?(?:\b|\d)) | d (?=(?:ays?)?(?:\b|\d)) | w (?=(?:eeks?)?(?:\b|\d)) | mon (?=(?:(?:th)?s?)?(?:\b|\d)) ) ) [^\d]*?(?=\b|\d) # do only extract start of string | (?<text> .+) ~uix REGEX; $array = []; foreach($tests as $case){ $text = ""; $time = preg_replace_callback ($reg1, function($matches) use (&$text) { if (isset($matches['text'])) { $text = trim($matches['text']); return ''; } switch($matches['time']){ case 's': $t = ' sec '; break; case 'm': $t = ' min '; break; case 'h': $t = ' hour '; break; case 'd': $t = ' day '; break; case 'w': $t = ' week '; break; case 'mon': $t = ' month '; break; } return $matches['int'].$t; }, $case); if ($time != "" && $text != "") { $array[] = [$time, $text]; } } return $array; } $normalized = separateAndNormalizeTimeSpec($tests); print_r($normalized);

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.0040.01117.00
8.3.50.0220.01022.28
8.3.40.0040.01119.17
8.3.30.0030.01219.17
8.3.20.0040.00420.48
8.3.10.0060.00619.23
8.3.00.0000.00820.69
8.2.180.0150.00616.75
8.2.170.0140.00722.96
8.2.160.0030.01720.47
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00422.38
8.2.120.0050.00326.35
8.2.110.0100.01322.11
8.2.100.0080.00418.34
8.2.90.0040.00418.41
8.2.80.0040.00419.28
8.2.70.0030.00518.29
8.2.60.0000.01018.30
8.2.50.0050.00318.10
8.2.40.0040.00420.67
8.2.30.0000.00719.55
8.2.20.0030.00618.21
8.2.10.0050.00318.30
8.2.00.0000.00818.12
8.1.280.0160.00625.92
8.1.270.0000.00824.04
8.1.260.0080.00028.09
8.1.250.0000.00828.09
8.1.240.0060.00321.03
8.1.230.0040.00821.22
8.1.220.0000.00817.74
8.1.210.0040.00419.03
8.1.200.0040.00817.60
8.1.190.0000.00817.73
8.1.180.0080.00018.10
8.1.170.0030.00618.90
8.1.160.0050.00222.16
8.1.150.0000.00819.07
8.1.140.0000.00819.76
8.1.130.0000.00717.79
8.1.120.0060.00317.76
8.1.110.0030.00617.69
8.1.100.0040.00417.70
8.1.90.0040.00417.69
8.1.80.0040.00417.59
8.1.70.0030.00317.70
8.1.60.0090.00017.71
8.1.50.0040.00417.71
8.1.40.0000.00817.66
8.1.30.0050.00317.86
8.1.20.0000.00817.89
8.1.10.0000.00817.75
8.1.00.0000.00917.72
8.0.300.0060.00320.29
8.0.290.0030.00617.00
8.0.280.0040.00418.48
8.0.270.0030.00317.43
8.0.260.0060.00017.49
8.0.250.0080.00017.30
8.0.240.0060.00317.31
8.0.230.0000.00717.22
8.0.220.0080.00017.32
8.0.210.0000.00817.25
8.0.200.0030.00317.39
8.0.190.0000.01117.24
8.0.180.0040.00417.32
8.0.170.0060.00317.32
8.0.160.0070.00017.30
8.0.150.0000.00717.23
8.0.140.0050.00317.15
8.0.130.0000.00613.69
8.0.120.0040.00417.17
8.0.110.0070.00017.27
8.0.100.0040.00417.34
8.0.90.0030.00517.33
8.0.80.0060.00917.38
8.0.70.0060.00317.19
8.0.60.0000.00817.29
8.0.50.0030.00517.36
8.0.30.0080.01317.46
8.0.20.0140.00617.48
8.0.10.0030.00517.36
8.0.00.0110.00717.05
7.4.330.0030.00315.31
7.4.320.0030.00316.96
7.4.300.0000.00616.96
7.4.290.0000.00716.79
7.4.280.0030.00516.88
7.4.270.0040.00416.83
7.4.260.0050.00316.87
7.4.250.0040.00416.96
7.4.240.0040.00416.99
7.4.230.0000.00717.09
7.4.220.0040.01516.79
7.4.210.0110.00316.82
7.4.200.0040.00416.99
7.4.160.0100.00716.84
7.4.150.0130.01317.40
7.4.140.0130.00917.86
7.4.130.0090.00916.90
7.4.120.0070.01116.81
7.4.110.0090.00917.03
7.4.100.0100.01017.06
7.4.90.0060.01216.85
7.4.80.0180.00319.39
7.4.70.0110.00617.03
7.4.60.0140.00416.77
7.4.50.0040.01116.92
7.4.40.0100.00716.97
7.4.30.0070.01016.75
7.4.00.0070.01015.09
7.3.330.0000.00513.56
7.3.320.0060.00013.54
7.3.310.0050.00316.71
7.3.300.0040.00416.73
7.3.290.0090.00916.67
7.3.280.0100.00916.63
7.3.270.0090.00817.40
7.3.260.0120.00816.83
7.3.250.0140.00416.71
7.3.240.0120.00716.82
7.3.230.0110.00616.72
7.3.210.0000.01716.80
7.3.200.0090.00916.84
7.3.190.0040.01216.69
7.3.180.0040.01816.83
7.3.170.0070.01017.03
7.3.160.0110.00716.68
7.2.330.0140.00416.82
7.2.320.0070.01016.93
7.2.310.0090.00917.07
7.2.300.0060.01216.98
7.2.290.0040.01516.77
7.2.60.0090.00317.25
7.1.200.0000.01315.86
7.1.70.0000.01017.33
7.1.60.0040.00717.39
7.1.00.0030.07322.57
7.0.200.0310.00315.13
7.0.110.0170.06020.32
7.0.100.0070.05720.21
7.0.90.0030.06720.40
7.0.80.0170.05020.45
7.0.70.0130.05720.38
7.0.60.0130.07720.05
7.0.50.0600.04720.25
7.0.40.0270.05720.34
7.0.30.0370.04720.37
7.0.20.0300.05720.32
7.0.10.0400.06720.31
7.0.00.0230.07020.31
5.6.260.0230.04321.07
5.6.250.0130.06320.89
5.6.240.0100.06320.77
5.6.230.0100.06021.00
5.6.220.0130.06020.87
5.6.210.0130.05320.96
5.6.200.0130.05721.07
5.6.190.0170.06020.84
5.6.180.0200.04721.02
5.6.170.0000.06320.93
5.6.160.0130.05720.85
5.6.150.0100.06320.81
5.6.140.0100.06321.09
5.6.130.0170.05321.07
5.6.120.0170.05321.00
5.6.110.0130.05721.05
5.6.100.0030.06720.94
5.6.90.0230.04021.08
5.6.80.0100.06320.20
5.6.70.0100.05320.39
5.6.60.0130.05320.23
5.6.50.0100.05020.25
5.6.40.0070.05720.17
5.6.30.0100.05720.21
5.6.20.0000.06320.37
5.6.10.0130.04720.36
5.6.00.0000.06320.20

preferences:
62.82 ms | 401 KiB | 5 Q