3v4l.org

run code in 300+ PHP versions simultaneously
<?php function saveCityZipCode(string $city, string $zipCode): void { var_dump($city, $zipCode); } $address = 'Studio 5, One Infinite Loop, Cupertino 95014'; preg_match('/\s*([^,]+?)\s*(\d+)$/', $address, $m) or throw new Exception('Failed to parse city and zipcode of address'); saveCityZipCode(...array_slice($m, 1)); // or just saveCityZipCode($m[1], $m[2]); // named capture groups can be spread too (but I probably wouldn't until PHP makes a PREG_NO_INDEXED_KEYS flag). echo "\n---\n"; preg_match('/\s*(?<city>[^,]+?)\s*(?<zipCode>\d+)$/', $address, $m) or throw new Exception('Failed to parse city and zipcode of address'); saveCityZipCode(...array_filter($m, fn($k) => !is_int($k), ARRAY_FILTER_USE_KEY));

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.00816.89
8.5.00.0120.01020.15
8.4.160.0100.01323.87
8.4.150.0010.00014.05
8.4.140.0140.01017.70
8.4.130.0120.00817.82
8.4.120.0110.00920.62
8.4.110.0100.01022.70
8.4.100.0100.01117.90
8.4.90.0140.00717.88
8.4.80.0120.00817.82
8.4.70.0120.00418.00
8.4.60.0140.00618.81
8.4.50.0090.01219.75
8.4.40.0100.01017.70
8.4.30.0060.01318.82
8.4.20.0140.00719.78
8.4.10.0120.00319.43
8.3.280.0130.00818.56
8.3.270.0110.00916.71
8.3.260.0120.00816.62
8.3.250.0090.00919.00
8.3.240.0080.01116.59
8.3.230.0090.01016.81
8.3.220.0060.00218.78
8.3.210.0060.00216.77
8.3.200.0120.00817.02
8.3.190.0090.00518.88
8.3.180.0100.00718.58
8.3.170.0040.01520.70
8.3.160.0130.00617.20
8.3.150.0120.00317.14
8.3.140.0110.00716.64
8.3.130.0040.01116.78
8.3.120.0000.00718.84
8.3.110.0090.00020.94
8.3.100.0060.01024.06
8.3.90.0080.00026.77
8.3.80.0100.00018.55
8.3.70.0160.00616.63
8.3.60.0290.00616.58
8.3.50.0070.01017.04
8.3.40.0350.00319.26
8.3.30.0240.01017.50
8.3.20.0340.00617.36
8.3.10.0270.01317.50
8.3.00.0280.01317.63
8.2.290.0130.00622.52
8.2.280.0070.00418.31
8.2.270.0120.00917.14
8.2.260.0040.00418.77
8.2.250.0030.00618.89
8.2.240.0000.00819.08
8.2.230.0100.00022.58
8.2.220.0080.00037.54
8.2.210.0080.00026.77
8.2.200.0030.00616.88
8.2.190.0330.00016.58
8.2.180.0370.00316.58
8.2.170.0340.00717.74
8.2.160.0320.00917.59
8.2.150.0300.01017.60
8.2.140.0370.00717.50
8.2.130.0290.00917.50
8.2.120.0350.00317.21
8.2.110.0200.01617.25
8.2.100.0240.01017.50
8.2.90.0270.00817.50
8.2.80.0260.00617.50
8.2.70.0220.01117.25
8.2.60.0320.00017.50
8.2.50.0310.00417.38
8.2.40.0270.00317.63
8.2.30.0190.01017.46
8.2.20.0240.00817.48
8.2.10.0310.00317.36
8.2.00.0280.00617.50
8.1.330.0170.00116.70
8.1.320.0070.01416.27
8.1.310.0090.00916.70
8.1.300.0100.00016.90
8.1.290.0070.00318.88
8.1.280.0280.00316.58
8.1.270.0340.00016.99
8.1.260.0300.00917.25
8.1.250.0280.00417.47
8.1.240.0230.01017.23
8.1.230.0230.00917.24
8.1.220.0280.00317.38
8.1.210.0120.01617.25
8.1.200.0270.00317.50
8.1.190.0240.00617.38
8.1.180.0210.01117.38
8.1.170.0200.00817.00
8.1.160.0230.00617.25
8.1.150.0270.00317.25
8.1.140.0210.01417.25
8.1.130.0200.01017.63
8.1.120.0280.00017.50
8.1.110.0190.01217.00
8.1.100.0240.00817.25
8.1.90.0180.01117.50
8.1.80.0280.00317.38
8.1.70.0240.01017.50
8.1.60.0230.01517.50
8.1.50.0260.00716.88
8.1.40.0270.00717.50
8.1.30.0350.00317.63
8.1.20.0260.01317.48
8.1.10.0280.00317.13
8.1.00.0290.00317.12

preferences:
29.62 ms | 403 KiB | 5 Q