3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class testAPI { private array $employee; private array $template; /** * testAPI constructor. * @param array $employee – массив с данными о работнике * @param array $template — массив с шаблонами */ public function __construct(array $employee, array $template) { $this->employee = $employee; $this->template = $template; } public function getApiPath(): array { return array_map(function () { return preg_replace_callback( '#%(.*)%#isU', function (array $matches) { return $this->employee[$matches[1]]; }, $this->template ); }, array_values($this->template) ); } } $apiTemplatesSet1 = [ '/api/items/%id%/%name%', '/api/items/%id%/%role%', '/api/items/%id%/%salary%' ]; $user = [ 'id' => 20, 'name' => 'John Dow', 'role' => 'QA', 'salary' => 100 ]; $test = new testAPI($user, $apiTemplatesSet1); echo '<pre>'; print_r($test->getApiPath()); echo '</pre>';

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.4.130.0140.00718.55
8.4.120.0090.00718.53
8.4.110.0150.00718.73
8.4.100.0110.00918.25
8.4.90.0100.01020.44
8.4.80.0050.00320.69
8.4.70.0120.00519.02
8.4.60.0120.00920.61
8.4.50.0110.00820.55
8.4.40.0060.00318.09
8.4.30.0130.00720.48
8.4.20.0070.01018.00
8.4.10.0080.00019.88
8.3.250.0110.00818.75
8.3.240.0140.00416.58
8.3.230.0090.00716.76
8.3.220.0060.00318.98
8.3.210.0120.00716.66
8.3.200.0040.00416.95
8.3.190.0080.00917.37
8.3.180.0070.01218.88
8.3.170.0070.01117.06
8.3.160.0180.00016.80
8.3.150.0120.00616.61
8.3.140.0120.00616.99
8.3.130.0040.01118.74
8.3.120.0030.00619.08
8.3.110.0090.00320.94
8.3.100.0030.00618.68
8.3.90.0040.00426.77
8.3.80.0060.00316.63
8.3.70.0070.00716.59
8.3.60.0190.00018.68
8.3.50.0160.00323.57
8.3.40.0000.01519.14
8.3.30.0070.00719.05
8.3.20.0060.00320.71
8.3.10.0030.00621.90
8.3.00.0040.00421.76
8.2.290.0090.01117.57
8.2.280.0090.00918.52
8.2.270.0110.00716.88
8.2.260.0090.00617.10
8.2.250.0060.00918.92
8.2.240.0070.01017.30
8.2.230.0060.00322.58
8.2.220.0090.00024.06
8.2.210.0040.00426.77
8.2.200.0050.00516.50
8.2.190.0070.00716.58
8.2.180.0140.00316.88
8.2.170.0090.00622.96
8.2.160.0000.01420.44
8.2.150.0080.00024.18
8.2.140.0070.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00426.16
8.2.110.0030.00620.38
8.2.100.0120.00318.03
8.2.90.0040.00419.36
8.2.80.0080.00017.97
8.2.70.0050.00317.75
8.2.60.0060.00318.05
8.2.50.0030.00618.07
8.2.40.0050.00519.95
8.2.30.0030.00518.04
8.2.20.0050.00318.22
8.2.10.0050.00319.32
8.2.00.0040.00419.40
8.1.330.0130.00616.33
8.1.320.0120.00916.47
8.1.310.0110.00417.00
8.1.300.0030.01617.96
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0080.00022.10
8.1.260.0090.00026.35
8.1.250.0080.00828.09
8.1.240.0030.00624.02
8.1.230.0000.01117.83
8.1.220.0030.00517.74
8.1.210.0090.00518.77
8.1.200.0030.00617.48
8.1.190.0080.00017.48
8.1.180.0050.00318.10
8.1.170.0000.00818.62
8.1.160.0050.00518.88
8.1.150.0080.00018.97
8.1.140.0000.00820.72
8.1.130.0000.00720.28
8.1.120.0040.00417.64
8.1.110.0000.00717.63
8.1.100.0040.00417.50
8.1.90.0040.00417.64
8.1.80.0080.00017.62
8.1.70.0030.00317.66
8.1.60.0030.00517.63
8.1.50.0030.00517.66
8.1.40.0090.00017.61
8.1.30.0100.00317.87
8.1.20.0040.00417.85
8.1.10.0030.00617.73
8.1.00.0000.00817.66
8.0.300.0080.00018.77
8.0.290.0040.00416.88
8.0.280.0070.00018.41
8.0.270.0000.00718.20
8.0.260.0030.00320.04
8.0.250.0000.00817.05
8.0.240.0040.00417.09
8.0.230.0040.00417.13
8.0.220.0030.00316.88
8.0.210.0040.00417.02
8.0.200.0060.00017.14
8.0.190.0040.00416.97
8.0.180.0040.00417.02
8.0.170.0060.00317.07
8.0.160.0040.00417.02
8.0.150.0040.00416.90
8.0.140.0000.00717.05
8.0.130.0030.00313.47
8.0.120.0000.00716.89
8.0.110.0040.00416.89
8.0.100.0000.00717.07
8.0.90.0000.00717.04
8.0.80.0000.01517.01
8.0.70.0050.00217.07
8.0.60.0000.00716.91
8.0.50.0000.00717.08
8.0.30.0130.00317.43
8.0.20.0110.00917.17
8.0.10.0000.00817.13
8.0.00.0090.01216.96
7.4.330.0000.00516.70
7.4.320.0070.00016.80
7.4.300.0000.00716.71
7.4.290.0000.00816.73
7.4.280.0040.00416.82
7.4.270.0050.00216.74
7.4.260.0000.00613.42
7.4.250.0030.00316.77
7.4.240.0040.00416.63
7.4.230.0030.00316.85
7.4.220.0030.00516.80
7.4.210.0110.00416.77
7.4.200.0030.00316.85
7.4.140.0100.01317.86
7.4.130.0110.00816.75
7.4.120.0110.01116.67
7.4.110.0090.00916.71
7.4.100.0060.01216.79
7.4.90.0060.01616.88
7.4.80.0060.01219.39
7.4.70.0090.00816.74
7.4.60.0110.00616.48
7.4.50.0100.00616.46
7.4.40.0090.00916.65
7.4.30.0140.00216.60
7.4.20.0110.00716.70
7.4.10.0100.00716.70
7.4.00.0070.01016.64
7.3.330.0000.00716.13
7.3.320.0000.00513.10
7.3.310.0050.00316.07
7.3.300.0000.00716.08
7.3.290.0050.00916.14
7.3.280.0160.00316.10
7.3.260.0030.01316.18
7.3.240.0100.00916.24
7.3.230.0030.01816.33
7.3.210.0150.00616.26
7.3.200.0040.01116.18
7.3.190.0110.01116.14
7.3.180.0100.00716.19
7.3.170.0090.00716.19
7.3.160.0120.00416.21
7.3.150.0120.00316.14
7.3.140.0080.01016.21
7.3.130.0100.00916.10
7.3.120.0090.00916.21
7.3.110.0120.00616.27
7.3.100.0090.00816.25
7.3.90.0110.00716.14
7.3.80.0090.00716.23
7.3.70.0050.01316.14
7.3.60.0060.01316.11
7.3.50.0070.01016.13
7.3.40.0030.01416.20
7.3.30.0050.01016.11
7.3.20.0100.01016.17
7.3.10.0070.01116.13
7.3.00.0110.00716.02
7.2.330.0120.00616.39
7.2.320.0110.00716.29
7.2.310.0110.00616.38
7.2.300.0050.01116.32
7.2.290.0110.00616.20
7.2.280.0080.00916.19
7.2.270.0060.01016.28
7.2.260.0070.01216.17
7.2.250.0110.00816.17
7.2.240.0030.01516.37
7.2.230.0080.01216.35
7.2.220.0080.01016.34
7.2.210.0070.01116.34
7.2.200.0080.00916.20
7.2.190.0070.01316.17
7.2.180.0080.00816.19
7.2.170.0080.00916.15
7.2.160.0110.00616.17
7.2.150.0130.00416.32
7.2.140.0100.00816.33
7.2.130.0080.00916.26
7.2.120.0080.01016.28
7.2.110.0240.00916.19
7.2.100.0070.01016.23
7.2.90.0100.00816.24
7.2.80.0110.00916.25
7.2.70.0090.00916.24
7.2.60.0090.01116.09
7.2.50.0140.00516.34
7.2.40.0090.01116.25
7.2.30.0080.01116.32
7.2.20.0080.01116.37
7.2.10.0080.00816.21
7.2.00.0090.00816.36

preferences:
108.06 ms | 403 KiB | 5 Q