3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Some strings to test our code */ $testStrings=[ "adress=example.com port=464", "adress =example.com\nport=4645", "port=1 protocol=https adress= example.com", ]; /** Test for each string */ foreach($testStrings as $string) { print "\n\nTESTING:'".escapeshellarg($string)."'\n"; /** First method - does not match them all */ if(preg_match('/\badress=([a-z\.]*)\s+port=(\d*)/',$string,$matches)) { print "Matched {$matches[1]}:{$matches[2]}\n"; } /** Second method - get param/value pairs first, then check them */ if(preg_match_all('/\b(?P<param>[^\d\s]\S*)\s*=\s*(?P<value>\S*)(?:\s|$)/m',$string,$matches)) { //var_dump($matches); // Uncomment to see the raw data. $i=0; // We need an index. foreach($matches['param'] as $param) { $value=$matches['value'][$i]; // Put value in local $value $i++; switch($param) { // Find parameters we know, complain if needed. case "adress": print "ADDRESS IS $value\n"; break; case "port": if(($result=preg_match('/^\d{3}$/',$value))) { var_dump($result); print "PORT IS $value\n"; } else { print "PORT MUST HAVE EXACTLY 3 DIGITS - Got: $value\n"; } break; default: print "UNKNOWN PARAMETER $param=$value\n"; } } } }

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.5.10.0110.00917.07
8.5.00.0100.01120.16
8.4.150.0010.00114.05
8.4.140.0140.00717.70
8.4.130.0130.00718.65
8.4.120.0080.01020.81
8.4.110.0050.00422.39
8.4.100.0060.00417.98
8.4.90.0090.00718.84
8.4.80.0120.00917.93
8.4.70.0090.00718.18
8.4.60.0130.00824.07
8.4.50.0120.00918.58
8.4.40.0150.00317.97
8.4.30.0140.00717.55
8.4.20.0060.00618.00
8.4.10.0060.00319.82
8.3.280.0100.01118.63
8.3.270.0120.00816.95
8.3.260.0100.01016.77
8.3.250.0070.00319.07
8.3.240.0150.00516.92
8.3.230.0050.00416.79
8.3.220.0090.01117.51
8.3.210.0060.00217.10
8.3.200.0060.00316.79
8.3.190.0160.00517.32
8.3.180.0040.00417.25
8.3.170.0140.00320.78
8.3.160.0160.00316.72
8.3.150.0110.00717.11
8.3.140.0000.00817.20
8.3.130.0170.00318.45
8.3.120.0060.00319.05
8.3.110.0030.00620.94
8.3.100.0060.00324.06
8.3.90.0070.00026.77
8.3.80.0060.00316.88
8.3.70.0070.01416.75
8.3.60.0060.01216.88
8.3.50.0110.00917.65
8.3.40.0060.00918.96
8.3.30.0070.00718.80
8.3.20.0050.00320.33
8.3.10.0030.00622.09
8.3.00.0000.00823.61
8.2.290.0130.01120.51
8.2.280.0130.00817.10
8.2.270.0110.00717.19
8.2.260.0030.00618.58
8.2.250.0030.00617.04
8.2.240.0060.00317.26
8.2.230.0060.00322.58
8.2.220.0030.00737.54
8.2.210.0060.00926.77
8.2.200.0030.00617.00
8.2.190.0150.00316.63
8.2.180.0130.00318.66
8.2.170.0040.01119.33
8.2.160.0170.00022.96
8.2.150.0000.00725.66
8.2.140.0000.00824.66
8.2.130.0070.00319.57
8.2.120.0060.00326.35
8.2.110.0060.00319.27
8.2.100.0110.00017.88
8.2.90.0040.00418.00
8.2.80.0060.00319.00
8.2.70.0040.00417.75
8.2.60.0040.00418.00
8.2.50.0040.00417.88
8.2.40.0040.00419.33
8.2.30.0040.00419.50
8.2.20.0040.00418.07
8.2.10.0070.00018.07
8.2.00.0040.00418.18
8.1.330.0080.01221.91
8.1.320.0120.01016.39
8.1.310.0050.00318.69
8.1.300.0160.00317.96
8.1.290.0090.00318.88
8.1.280.0100.01025.92
8.1.270.0090.00023.76
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0050.00522.14
8.1.230.0090.00317.79
8.1.220.0030.00618.79
8.1.210.0080.00018.77
8.1.200.0040.00417.60
8.1.190.0080.00017.36
8.1.180.0040.00418.10
8.1.170.0000.00918.85
8.1.160.0000.00818.96
8.1.150.0070.00020.17
8.1.140.0000.00819.53
8.1.130.0070.00017.57
8.1.120.0020.00517.70
8.1.110.0080.00017.72
8.1.100.0000.00817.58
8.1.90.0080.00017.61
8.1.80.0090.00017.55
8.1.70.0050.00217.67
8.1.60.0050.00317.78
8.1.50.0040.00817.55
8.1.40.0070.00317.70
8.1.30.0060.00317.91
8.1.20.0050.00317.69
8.1.10.0000.00817.72
8.1.00.0000.00817.60
8.0.300.0070.00318.77
8.0.290.0000.00817.13
8.0.280.0000.00718.59
8.0.270.0050.00317.02
8.0.260.0000.00717.02
8.0.250.0070.00017.09
8.0.240.0030.00617.14
8.0.230.0000.00717.12
8.0.220.0040.00416.97
8.0.210.0040.00417.09
8.0.200.0000.00717.04
8.0.190.0080.00017.16
8.0.180.0000.00717.14
8.0.170.0070.00017.06
8.0.160.0070.00017.01
8.0.150.0040.00416.96
8.0.140.0040.00417.00
8.0.130.0000.00513.51
8.0.120.0080.00016.96
8.0.110.0000.00717.07
8.0.100.0040.00417.04
8.0.90.0050.00317.06
8.0.80.0100.00717.13
8.0.70.0030.00516.87
8.0.60.0000.00717.11
8.0.50.0040.00416.94
8.0.30.0100.01117.27
8.0.20.0120.00817.40
8.0.10.0040.00417.29
8.0.00.0140.00317.09
7.4.330.0050.00015.55
7.4.320.0060.00016.87
7.4.300.0000.00616.83
7.4.290.0000.00716.86
7.4.280.0000.00916.66
7.4.270.0070.00016.88
7.4.260.0000.00716.64
7.4.250.0000.00716.73
7.4.240.0000.00916.76
7.4.230.0000.00816.61
7.4.220.0130.00616.87
7.4.210.0140.00016.80
7.4.200.0000.00716.78
7.4.160.0100.00516.72
7.4.150.0000.01817.40
7.4.140.0080.01117.86
7.4.130.0070.01116.70
7.4.120.0130.00716.79
7.4.110.0100.00716.61
7.4.100.0100.00716.68
7.4.90.0000.01716.80
7.4.80.0140.02519.39
7.4.70.0170.00716.62
7.4.60.0100.01316.67
7.4.50.0070.00716.83
7.4.40.0090.01216.70
7.4.30.0090.01416.83
7.4.00.0040.01114.99
7.3.330.0030.00313.39
7.3.320.0060.00013.33
7.3.310.0000.00816.47
7.3.300.0030.00316.38
7.3.290.0100.00616.45
7.3.280.0090.00816.49
7.3.270.0030.01917.40
7.3.260.0130.00816.74
7.3.250.0090.01016.49
7.3.240.0080.00916.55
7.3.230.0080.00816.85
7.3.210.0060.01516.43
7.3.200.0110.00816.89
7.3.190.0060.01017.00
7.3.180.0100.01316.50
7.3.170.0090.00916.55
7.3.160.0040.01216.43
7.2.330.0090.00916.71
7.2.320.0120.01216.79
7.2.310.0090.00916.81
7.2.300.0120.00816.87
7.2.290.0110.00716.98
7.2.110.0160.00616.68
7.2.60.0070.00717.18
7.1.200.0090.00615.98
7.1.100.0850.01616.41
7.1.90.1590.00316.41
7.1.80.1830.00616.51
7.1.70.1100.00715.55
7.1.60.1660.01033.70
7.1.50.2040.01033.17
7.1.40.3810.00732.84
7.1.30.3550.01632.96
7.1.20.3410.01332.95
7.1.10.1970.00314.95
7.1.00.2900.00715.10
7.0.240.0080.01216.10
7.0.230.0040.01316.25
7.0.220.1370.01216.20
7.0.210.1080.01314.91
7.0.200.1740.00315.25
7.0.190.3010.01014.91
7.0.180.3860.01214.59
7.0.170.4200.01014.55
7.0.160.4180.01314.71
7.0.150.2100.00614.65
7.0.140.2850.00714.85
7.0.130.2200.00715.13
7.0.120.2120.00715.03
7.0.110.1840.01014.75
7.0.100.1370.01114.70
7.0.90.0370.00714.81
7.0.80.0150.01114.70
7.0.70.2950.00714.74
7.0.60.3610.01014.50
7.0.50.4210.01014.95
7.0.40.3400.01314.86
7.0.30.2420.00715.11
7.0.20.2140.00714.79
7.0.10.2650.00714.82
7.0.00.2480.00715.10

preferences:
170.27 ms | 403 KiB | 5 Q