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) { return $this->data[$key[1]]; #echo '<pre>' . print_r($input, true); #return array_map([$this, 'replace'], $input); } private function replace(string $key): string { return $this->data[trim($key, '%')]; } } $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.0160.00318.43
8.3.50.0040.01116.51
8.3.40.0070.00718.78
8.3.30.0080.00818.84
8.3.20.0090.00021.73
8.3.10.0040.00421.80
8.3.00.0070.00021.94
8.2.180.0040.01418.72
8.2.170.0180.00019.17
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0040.00419.61
8.2.110.0000.00920.48
8.2.100.0120.00018.09
8.2.90.0030.00518.00
8.2.80.0080.00418.84
8.2.70.0050.00517.88
8.2.60.0040.00418.05
8.2.50.0000.00818.05
8.2.40.0080.00018.34
8.2.30.0030.00319.49
8.2.20.0050.00218.05
8.2.10.0070.00019.48
8.2.00.0040.00419.43
8.1.280.0140.00025.92
8.1.270.0040.00421.97
8.1.260.0030.00626.35
8.1.250.0080.00028.09
8.1.240.0030.00720.79
8.1.230.0080.00317.89
8.1.220.0040.00417.78
8.1.210.0050.00318.77
8.1.200.0030.00617.60
8.1.190.0030.00517.47
8.1.180.0070.00718.10
8.1.170.0040.00417.62
8.1.160.0000.00718.80
8.1.150.0030.00618.92
8.1.140.0030.00520.80
8.1.130.0080.00020.22
8.1.120.0050.00217.65
8.1.110.0040.00417.59
8.1.100.0030.00617.68
8.1.90.0070.00017.62
8.1.80.0000.00717.64
8.1.70.0030.00317.64
8.1.60.0040.00417.59
8.1.50.0050.00317.61
8.1.40.0040.00417.59
8.1.30.0000.00817.79
8.1.20.0080.00017.86
8.1.10.0030.00617.64
8.1.00.0050.00317.57
8.0.300.0060.00318.77
8.0.290.0090.00016.75
8.0.280.0030.00318.45
8.0.270.0000.00918.08
8.0.260.0000.00619.99
8.0.250.0000.00717.06
8.0.240.0040.00417.04
8.0.230.0080.00017.10
8.0.220.0000.00816.93
8.0.210.0050.00317.07
8.0.200.0000.00717.01
8.0.190.0040.00417.04
8.0.180.0040.00417.02
8.0.170.0000.00817.05
8.0.160.0040.00417.05
8.0.150.0040.00416.91
8.0.140.0040.00416.93
8.0.130.0030.00313.50
8.0.120.0000.00716.91
8.0.110.0000.00717.12
8.0.100.0080.00017.05
8.0.90.0030.00616.89
8.0.80.0090.00717.00
8.0.70.0070.00017.04
8.0.60.0040.00416.90
8.0.50.0000.00817.10
8.0.30.0140.00317.30
8.0.20.0150.01117.25
8.0.10.0030.00616.96
8.0.00.0150.00916.90
7.4.330.0000.00516.91
7.4.320.0050.00216.74
7.4.300.0030.00316.81
7.4.290.0030.00616.83
7.4.280.0040.00416.72
7.4.270.0070.00016.69
7.4.260.0000.00613.62
7.4.250.0030.00516.67
7.4.240.0030.00516.78
7.4.230.0030.00316.73
7.4.220.0050.00316.71
7.4.210.0080.01116.86
7.4.200.0080.00016.58
7.4.140.0160.01017.86
7.4.130.0080.01416.76
7.4.120.0060.01316.88
7.4.110.0130.00316.63
7.4.100.0100.01016.67
7.4.90.0100.00716.68
7.4.80.0130.00719.39
7.4.70.0060.01216.64
7.4.60.0150.00316.58
7.4.50.0070.00716.54
7.4.40.0110.00616.76
7.4.20.0160.00016.75
7.4.10.0080.00816.67
7.4.00.0100.00616.68
7.3.330.0070.00016.52
7.3.320.0070.00013.48
7.3.310.0080.00016.49
7.3.300.0030.00316.54
7.3.290.0090.01016.51
7.3.260.0100.00716.74
7.3.240.0110.00916.69
7.3.230.0090.01116.65
7.3.210.0140.00316.80
7.3.200.0060.01116.61
7.3.190.0140.00316.67
7.3.180.0100.01116.59
7.3.170.0120.00416.75
7.3.160.0230.00016.54
7.3.130.0040.01616.68
7.3.120.0070.01016.61
7.3.110.0000.01616.55
7.3.100.0070.01116.84
7.3.90.0060.01516.71
7.3.80.0070.01416.68
7.3.70.0080.01316.66
7.3.60.0160.00616.60
7.3.50.0140.00816.65
7.3.40.0090.01216.56
7.3.30.0120.00916.68
7.3.20.0150.00416.64
7.3.10.0090.00916.72
7.3.00.0120.00616.57
7.2.330.0140.00416.95
7.2.320.0090.00916.69
7.2.310.0080.00816.72
7.2.300.0120.01416.84
7.2.290.0070.01417.03
7.2.260.0080.00816.96
7.2.250.0060.01216.95
7.2.240.0070.01316.71
7.2.230.0110.01116.86
7.2.220.0030.01216.63
7.2.210.0060.01616.88
7.2.200.0150.00816.70
7.2.190.0060.01716.66
7.2.180.0060.01016.71
7.2.170.0100.01416.80
7.2.160.0030.02016.73
7.2.150.0160.00617.05
7.2.140.0160.00817.01
7.2.130.0090.00916.93
7.2.120.0090.00916.99
7.2.110.0040.01416.89
7.2.100.0030.01416.84
7.2.90.0120.01116.82
7.2.80.0130.00617.02
7.2.70.0040.01517.09
7.2.60.0140.00916.86
7.2.50.0120.00616.95
7.2.40.0070.01316.98
7.2.30.0070.01116.86
7.2.20.0130.00316.75
7.2.10.0060.01016.83
7.2.00.0130.00516.84

preferences:
58.08 ms | 400 KiB | 5 Q