3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = [ 'id' => 1, 'name' => 'Ivan Ivanov', 'role' => 'developer', 'salary' => 100 ]; $apiTemplatesSet1 = [ '/api/items/%id%/%name%', '/api/items/%id%/%role%', '/api/items/%id%/%salary%' ]; class Invoker { private $data; public function __construct(array $data) { $this->data = $data; } public function __invoke(array $key): string { return $this->data[$key[1]]; } } $function = new Invoker($user); $result = array_map(function ($key) use ($function) { return preg_replace_callback('#%(.*)%#isU', $function, $key); } , array_values($apiTemplatesSet1)); echo '<pre>' . print_r($result, 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.60.0140.00716.63
8.3.50.0040.01116.49
8.3.40.0140.00718.80
8.3.30.0140.00019.00
8.3.20.0070.00321.81
8.3.10.0040.00421.73
8.3.00.0080.00021.85
8.2.180.0140.00418.66
8.2.170.0110.00419.27
8.2.160.0070.01022.96
8.2.150.0000.00825.66
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0040.00426.16
8.2.110.0060.00320.52
8.2.100.0140.00017.91
8.2.90.0050.00518.00
8.2.80.0000.00818.97
8.2.70.0000.00818.03
8.2.60.0000.00818.13
8.2.50.0030.00618.10
8.2.40.0000.00819.42
8.2.30.0030.00519.41
8.2.20.0000.00818.25
8.2.10.0000.00819.32
8.2.00.0000.00819.34
8.1.280.0060.00925.92
8.1.270.0080.00022.10
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.92
8.1.230.0110.00022.73
8.1.220.0090.00017.78
8.1.210.0060.00318.77
8.1.200.0050.00517.50
8.1.190.0030.00617.35
8.1.180.0080.00019.07
8.1.170.0040.00418.71
8.1.160.0000.00719.01
8.1.150.0050.00318.95
8.1.140.0040.00420.82
8.1.130.0030.00620.20
8.1.120.0000.00717.65
8.1.110.0030.00517.52
8.1.100.0060.00317.63
8.1.90.0040.00417.53
8.1.80.0000.00817.63
8.1.70.0050.00317.68
8.1.60.0000.00917.77
8.1.50.0030.00617.75
8.1.40.0030.00617.61
8.1.30.0060.00317.83
8.1.20.0040.00417.86
8.1.10.0080.00017.71
8.1.00.0050.00317.66
8.0.300.0060.00318.77
8.0.290.0060.00316.88
8.0.280.0000.00718.48
8.0.270.0030.00317.05
8.0.260.0030.00320.11
8.0.250.0070.00017.01
8.0.240.0060.00017.18
8.0.230.0030.00517.05
8.0.220.0070.00017.08
8.0.210.0070.00017.09
8.0.200.0000.00617.02
8.0.190.0060.00317.06
8.0.180.0030.00516.98
8.0.170.0000.00917.02
8.0.160.0040.00417.04
8.0.150.0050.00217.06
8.0.140.0070.00017.04
8.0.130.0030.00313.52
8.0.120.0000.00716.99
8.0.110.0000.00717.02
8.0.100.0000.00816.86
8.0.90.0040.00416.93
8.0.80.0100.00616.99
8.0.70.0060.00316.94
8.0.60.0000.00717.08
8.0.50.0050.00316.90
8.0.30.0140.00817.36
8.0.20.0170.00917.22
8.0.10.0040.00416.99
8.0.00.0100.01017.03
7.4.330.0000.00516.80
7.4.320.0070.00016.76
7.4.300.0030.00316.83
7.4.290.0040.00416.74
7.4.280.0040.00416.88
7.4.270.0030.00316.83
7.4.260.0000.00513.57
7.4.250.0000.00716.71
7.4.240.0070.00016.74
7.4.230.0000.00716.60
7.4.220.0020.00616.84
7.4.210.0080.01216.77
7.4.200.0030.00316.94
7.4.140.0110.00717.86
7.4.130.0100.01116.76
7.4.120.0130.00716.61
7.4.110.0130.01016.56
7.4.100.0110.00716.88
7.4.90.0100.00716.83
7.4.80.0150.00519.39
7.4.70.0000.01716.85
7.4.60.0140.00716.64
7.4.50.0070.00716.81
7.4.40.0160.00016.76
7.4.20.0100.00816.68
7.4.10.0110.00516.72
7.4.00.0060.01016.79
7.3.330.0030.00316.41
7.3.320.0000.00613.34
7.3.310.0000.00916.53
7.3.300.0040.00416.40
7.3.290.0040.00416.50
7.3.260.0130.00416.55
7.3.240.0120.00616.66
7.3.230.0030.01316.70
7.3.210.0060.01216.71
7.3.200.0030.01316.50
7.3.190.0030.01716.52
7.3.180.0100.01016.48
7.3.170.0130.00316.74
7.3.160.0170.00016.79
7.3.130.0090.00816.61
7.3.120.0110.00616.62
7.3.110.0090.00816.66
7.3.100.0100.00816.60
7.3.90.0120.00716.62
7.3.80.0110.00816.65
7.3.70.0120.00816.57
7.3.60.0060.01116.47
7.3.50.0030.01316.48
7.3.40.0100.01016.56
7.3.30.0090.01116.60
7.3.20.0080.01216.67
7.3.10.0090.01216.58
7.3.00.0090.01016.65
7.2.330.0120.00616.97
7.2.320.0160.00316.96
7.2.310.0160.00316.71
7.2.300.0190.00616.81
7.2.290.0070.01117.01
7.2.260.0050.01116.90
7.2.250.0080.01016.79
7.2.240.0080.01116.90
7.2.230.0080.01016.82
7.2.220.0080.01116.89
7.2.210.0060.01316.90
7.2.200.0090.00916.79
7.2.190.0080.01216.76
7.2.180.0070.01116.79
7.2.170.0090.01016.80
7.2.160.0110.00816.80
7.2.150.0120.01116.91
7.2.140.0100.01216.74
7.2.130.0150.01016.90
7.2.120.0100.01216.86
7.2.110.0090.01216.83
7.2.100.0130.00816.85
7.2.90.0110.01016.83
7.2.80.0100.01016.84
7.2.70.0100.00916.86
7.2.60.0120.00816.85
7.2.50.0070.01316.83
7.2.40.0110.00816.83
7.2.30.0080.01216.88
7.2.20.0110.00816.78
7.2.10.0140.00816.89
7.2.00.0130.00916.87

preferences:
62.02 ms | 401 KiB | 5 Q