3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Parses routes of the following form: * * "/user/{name}/{id:[0-9]+}" */ class Std { const VARIABLE_REGEX = <<<'REGEX' ~\{ \s* ([a-zA-Z][a-zA-Z0-9_]*) \s* (?: : \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*) )? \}~x REGEX; const DEFAULT_DISPATCH_REGEX = '[^/]+'; public function parse($route) { if (!preg_match_all( self::VARIABLE_REGEX, $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER )) { return [$route]; } $offset = 0; $routeData = []; foreach ($matches as $set) { if ($set[0][1] > $offset) { $routeData[] = substr($route, $offset, $set[0][1] - $offset); } $routeData[] = [ $set[1][0], isset($set[2]) ? trim($set[2][0]) : self::DEFAULT_DISPATCH_REGEX ]; $offset = $set[0][1] + strlen($set[0][0]); } if ($offset != strlen($route)) { $routeData[] = substr($route, $offset); } return $routeData; } } $Parser = new Std; var_dump( $Parser->parse("/user/{name}/{id:[0-9]+}/franchise") );

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.0160.00316.88
8.3.50.0130.00617.50
8.3.40.0090.00619.14
8.3.30.0070.00718.96
8.3.20.0040.00419.07
8.3.10.0050.00319.16
8.3.00.0060.00319.63
8.2.180.0070.01116.63
8.2.170.0150.00422.96
8.2.160.0040.01120.57
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0060.00926.16
8.2.120.0080.00021.09
8.2.110.0070.00321.13
8.2.100.0040.00818.03
8.2.90.0070.00319.47
8.2.80.0000.00919.39
8.2.70.0040.00417.75
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0030.00518.22
8.2.30.0060.00318.08
8.2.20.0070.00317.82
8.2.10.0030.00517.82
8.2.00.0050.00317.91
8.1.280.0040.01525.92
8.1.270.0030.00524.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.82
8.1.230.0060.00620.93
8.1.220.0030.00617.79
8.1.210.0060.00618.82
8.1.200.0040.00417.38
8.1.190.0040.00417.30
8.1.180.0050.00318.10
8.1.170.0000.00818.89
8.1.160.0070.00018.93
8.1.150.0000.00718.84
8.1.140.0040.00417.61
8.1.130.0000.00717.89
8.1.120.0040.00417.54
8.1.110.0050.00317.52
8.1.100.0050.00217.63
8.1.90.0040.00417.61
8.1.80.0000.00717.62
8.1.70.0030.00317.60
8.1.60.0040.00417.74
8.1.50.0000.00817.63
8.1.40.0030.00517.57
8.1.30.0030.00617.72
8.1.20.0030.00517.65
8.1.10.0000.00817.73
8.1.00.0000.00817.57
8.0.300.0000.00719.87
8.0.290.0040.00417.00
8.0.280.0030.00518.48
8.0.270.0030.00317.33
8.0.260.0000.00717.02
8.0.250.0020.00517.21
8.0.240.0040.00417.14
8.0.230.0000.00717.21
8.0.220.0030.00317.12
8.0.210.0040.00417.18
8.0.200.0040.00417.21
8.0.190.0050.00317.21
8.0.180.0080.00017.11
8.0.170.0000.00817.04
8.0.160.0040.00417.18
8.0.150.0030.00616.94
8.0.140.0080.00017.09
8.0.130.0050.00013.55
8.0.120.0000.00816.98
8.0.110.0080.00017.00
8.0.100.0000.00817.18
8.0.90.0050.00317.00
8.0.80.0080.00817.09
8.0.70.0040.00417.05
8.0.60.0040.00417.14
8.0.50.0000.00717.10
8.0.30.0040.02117.49
8.0.20.0100.00917.20
8.0.10.0070.00017.09
8.0.00.0140.00816.95
7.4.330.0050.00013.25
7.4.320.0000.00616.74
7.4.300.0040.00416.72
7.4.290.0030.00616.68
7.4.280.0030.00616.84
7.4.270.0000.00816.73
7.4.260.0050.00013.44
7.4.250.0000.00816.70
7.4.240.0060.00216.77
7.4.230.0080.00016.71
7.4.220.0130.00616.92
7.4.210.0060.01116.92
7.4.200.0070.00016.79
7.4.190.0000.00716.89
7.4.160.0060.00916.65
7.4.150.0150.00316.82
7.4.140.0110.01016.71
7.4.130.0120.00616.71
7.4.120.0040.01316.71
7.4.110.0090.01516.69
7.4.100.0080.00816.79
7.4.90.0060.01216.65
7.4.80.0110.01119.39
7.4.70.0120.00916.71
7.4.60.0080.00816.76
7.4.50.0080.00616.74
7.4.40.0120.00316.93
7.4.30.0150.00316.89
7.4.00.0090.00815.11
7.3.330.0030.00313.65
7.3.320.0030.00313.59
7.3.310.0080.00016.63
7.3.300.0030.00316.61
7.3.290.0110.00816.56
7.3.280.0100.00916.56
7.3.270.0100.00716.65
7.3.260.0090.00916.87
7.3.250.0120.00716.67
7.3.240.0190.00616.84
7.3.230.0120.00616.59
7.3.210.0110.00716.80
7.3.200.0090.01316.65
7.3.190.0120.00916.71
7.3.180.0070.01516.84
7.3.170.0160.00016.60
7.3.160.0090.00616.66
7.3.120.0080.00915.14
7.3.110.0130.00315.04
7.3.100.0090.00615.23
7.3.90.0070.00715.10
7.3.80.0030.01414.92
7.3.70.0090.00315.20
7.3.60.0030.01014.95
7.3.50.0150.00015.11
7.3.40.0040.01114.87
7.3.30.0070.00714.77
7.3.20.0000.01216.97
7.3.10.0060.00316.83
7.3.00.0040.00816.78
7.2.330.0040.01416.69
7.2.320.0100.01016.95
7.2.310.0080.01216.81
7.2.300.0070.01016.72
7.2.290.0080.00817.02
7.2.250.0100.01015.28
7.2.240.0070.01315.20
7.2.230.0030.01015.13
7.2.220.0030.01115.24
7.2.210.0040.01415.25
7.2.200.0060.01115.11
7.2.190.0090.00615.28
7.2.180.0030.01415.37
7.2.170.0000.01615.08
7.2.00.0000.01319.50
7.1.330.0040.01115.98
7.1.320.0000.01515.93
7.1.310.0060.00316.20
7.1.300.0060.00615.74
7.1.290.0030.01016.09
7.1.280.0000.00916.04
7.1.270.0070.00716.03
7.1.260.0070.00715.97
7.1.100.0040.01118.19
7.1.70.0020.00517.55
7.1.60.0160.00619.40
7.1.50.0090.01317.13
7.1.00.0030.07722.38
7.0.200.0000.00916.60
7.0.140.0030.07322.12
7.0.120.0030.03322.00
7.0.60.0130.03320.03
7.0.50.0100.07317.75
7.0.40.0130.08017.74
7.0.30.0030.05017.79
7.0.20.0130.06017.88
7.0.10.0130.07317.86
7.0.00.0070.08317.78
5.6.280.0030.07320.94
5.6.210.0100.03320.54
5.6.200.0000.07718.17
5.6.190.0070.08318.16
5.6.180.0100.08318.19
5.6.170.0100.07718.25
5.6.160.0130.03718.24
5.6.150.0070.06018.18
5.6.140.0030.04018.15
5.6.130.0100.05018.16
5.6.120.0100.04318.18
5.6.110.0000.04718.23
5.6.100.0100.03318.13
5.6.90.0030.04018.11
5.6.80.0100.03017.69
5.6.70.0000.04017.50
5.6.60.0030.03717.59
5.6.50.0030.04017.55
5.6.40.0000.04017.53
5.6.30.0030.04717.64
5.6.20.0000.04017.60
5.6.10.0100.03017.59
5.6.00.0000.04017.53
5.5.350.0100.03720.51
5.5.340.0100.07318.07
5.5.330.0130.07717.95
5.5.320.0030.08318.07
5.5.310.0030.06717.97
5.5.300.0000.06317.98
5.5.290.0070.03717.95
5.5.280.0100.03317.95
5.5.270.0030.04018.07
5.5.260.0070.04018.03
5.5.250.0030.04017.77
5.5.240.0000.04017.37
5.5.230.0030.04017.30
5.5.220.0030.03717.44
5.5.210.0070.03317.44
5.5.200.0030.04017.34
5.5.190.0070.03717.33
5.5.180.0000.04017.38
5.5.160.0000.04017.32
5.5.150.0030.04017.39
5.5.140.0100.03017.28
5.5.130.0000.04017.33
5.5.120.0030.03717.30
5.5.110.0030.04717.43
5.5.100.0070.03717.24
5.5.90.0000.04717.33
5.5.80.0030.04017.35
5.5.70.0070.06717.17
5.5.60.0070.07317.22
5.5.50.0100.04317.17
5.5.40.0030.05317.22
5.5.30.0070.07317.18
5.5.20.0130.06317.23
5.5.10.0130.07317.33
5.5.00.0200.03717.19
5.4.450.0000.05719.45
5.4.440.0000.04319.38
5.4.430.0000.04319.47
5.4.420.0100.03719.41
5.4.410.0000.04019.21
5.4.400.0000.04018.95
5.4.390.0000.04019.11
5.4.380.0070.03319.01
5.4.370.0000.04019.28
5.4.360.0030.03719.09
5.4.350.0030.03719.22
5.4.340.0070.04019.01
5.4.320.0070.03319.12
5.4.310.0000.04019.03
5.4.300.0230.02318.98
5.4.290.0000.04019.11
5.4.280.0030.03719.09
5.4.270.0070.03718.95
5.4.260.0030.04718.88
5.4.250.0030.07019.09
5.4.240.0070.07318.97
5.4.230.0030.07019.26
5.4.220.0100.07319.01
5.4.210.0100.07719.05
5.4.200.0100.06719.15
5.4.190.0070.04019.02
5.4.180.0100.07319.00
5.4.170.0000.05019.12
5.4.160.0170.06319.02
5.4.150.0070.07718.93
5.4.140.0000.07316.34
5.4.130.0130.06316.59
5.4.120.0030.07316.32
5.4.110.0030.04016.40
5.4.100.0030.07716.37
5.4.90.0070.07716.45
5.4.80.0000.08016.52
5.4.70.0030.07316.54
5.4.60.0130.07016.21
5.4.50.0130.05716.37
5.4.40.0000.04016.52
5.4.30.0030.07316.20
5.4.20.0030.07316.30
5.4.10.0000.07716.38
5.4.00.0100.07315.85
5.3.290.0030.03714.66
5.3.280.0130.06014.64
5.3.270.0070.07714.64
5.3.260.0070.04014.56
5.3.250.0030.08314.46
5.3.240.0030.06714.71
5.3.230.0030.08314.56
5.3.220.0070.04714.53
5.3.210.0030.05014.66
5.3.200.0000.08314.61
5.3.190.0070.05014.61
5.3.180.0000.08014.59
5.3.170.0130.04314.57
5.3.160.0070.04314.60
5.3.150.0030.06714.52
5.3.140.0070.04714.57
5.3.130.0100.06314.60
5.3.120.0030.08714.58
5.3.110.0130.07014.59
5.3.100.0000.07014.11
5.3.90.0100.06314.23
5.3.80.0070.08013.90
5.3.70.0070.07014.01
5.3.60.0070.07314.21
5.3.50.0100.07013.97
5.3.40.0130.06313.97
5.3.30.0170.04313.95
5.3.20.0030.08013.91
5.3.10.0070.07313.86
5.3.00.0030.04713.66
5.2.170.0070.04311.14
5.2.160.0070.06311.13
5.2.150.0100.04711.20
5.2.140.0100.04011.20
5.2.130.0030.04010.99
5.2.120.0070.06011.00
5.2.110.0030.04711.09
5.2.100.0030.06311.10
5.2.90.0030.03711.31
5.2.80.0070.05710.98
5.2.70.0070.06311.13
5.2.60.0100.06311.14
5.2.50.0030.05710.86
5.2.40.0130.05311.20
5.2.30.0070.06011.00
5.2.20.0070.06010.95
5.2.10.0070.06010.88
5.2.00.0130.03010.56
5.1.60.0100.05010.20
5.1.50.0030.0579.97
5.1.40.0070.05010.02
5.1.30.0000.05710.22
5.1.20.0300.02310.45
5.1.10.0070.03710.03
5.1.00.0030.05710.02
5.0.50.0000.0378.58
5.0.40.0030.0378.40
5.0.30.0030.0538.28
5.0.20.0030.0308.17
5.0.10.0030.0208.00
5.0.00.0000.0378.22
4.4.90.0000.0237.87
4.4.80.0070.0207.87
4.4.70.0000.0337.87
4.4.60.0030.0207.87
4.4.50.0000.0177.87
4.4.40.0030.0407.87
4.4.30.0000.0237.87
4.4.20.0070.0337.87
4.4.10.0030.0377.87
4.4.00.0000.0577.87
4.3.110.0000.0307.87
4.3.100.0000.0377.87
4.3.90.0030.0207.87
4.3.80.0070.0277.87
4.3.70.0070.0337.87
4.3.60.0000.0307.87
4.3.50.0000.0237.87
4.3.40.0000.0577.87
4.3.30.0000.0277.87
4.3.20.0000.0307.87
4.3.10.0000.0277.87
4.3.00.0030.0337.87

preferences:
42.29 ms | 401 KiB | 5 Q