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 preg_replace_callback( '#%(.*)%#isU', function (array $matches) { return $this->employee[$matches[1]]; }, $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(), true) . '</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.3.60.0140.00418.66
8.3.50.0100.00716.88
8.3.40.0110.00419.09
8.3.30.0040.01119.09
8.3.20.0070.00320.98
8.3.10.0040.00421.72
8.3.00.0000.00821.86
8.2.180.0060.01516.88
8.2.170.0070.00722.96
8.2.160.0100.00320.35
8.2.150.0040.00724.18
8.2.140.0070.00024.66
8.2.130.0000.00726.16
8.2.120.0000.00826.16
8.2.110.0070.00322.33
8.2.100.0060.00617.84
8.2.90.0040.00417.50
8.2.80.0040.00419.08
8.2.70.0040.00417.88
8.2.60.0040.00418.00
8.2.50.0040.00417.98
8.2.40.0050.00319.73
8.2.30.0000.00819.40
8.2.20.0020.00518.05
8.2.10.0000.00819.39
8.2.00.0000.00719.30
8.1.280.0100.01325.92
8.1.270.0070.00322.24
8.1.260.0040.00426.35
8.1.250.0070.00728.09
8.1.240.0060.00320.91
8.1.230.0060.00620.77
8.1.220.0050.00318.87
8.1.210.0040.00418.77
8.1.200.0080.00017.35
8.1.190.0040.00417.35
8.1.180.0090.00018.10
8.1.170.0000.00817.62
8.1.160.0000.00718.81
8.1.150.0000.00818.99
8.1.140.0080.00020.69
8.1.130.0080.00020.36
8.1.120.0070.00017.68
8.1.110.0030.00317.60
8.1.100.0040.00417.62
8.1.90.0040.00417.57
8.1.80.0060.00317.63
8.1.70.0000.00817.57
8.1.60.0000.00917.78
8.1.50.0000.00817.67
8.1.40.0040.00417.61
8.1.30.0070.00417.66
8.1.20.0050.00317.85
8.1.10.0030.00517.62
8.1.00.0040.00417.71
8.0.300.0040.00418.77
8.0.290.0000.00816.88
8.0.280.0030.00318.41
8.0.270.0000.00818.11
8.0.260.0040.00420.11
8.0.250.0040.00417.09
8.0.240.0070.00017.10
8.0.230.0030.00317.06
8.0.220.0040.00417.13
8.0.210.0000.00716.94
8.0.200.0030.00317.00
8.0.190.0050.00317.02
8.0.180.0060.00317.00
8.0.170.0040.00417.07
8.0.160.0000.00717.05
8.0.150.0070.00016.91
8.0.140.0000.00816.97
8.0.130.0030.00313.52
8.0.120.0000.00717.00
8.0.110.0040.00417.04
8.0.100.0040.00416.88
8.0.90.0030.00616.92
8.0.80.0150.00617.05
8.0.70.0000.00716.92
8.0.60.0000.00817.08
8.0.50.0000.00816.99
8.0.30.0130.00317.50
8.0.20.0060.01417.15
8.0.10.0000.00717.23
8.0.00.0110.00916.95
7.4.330.0030.00316.68
7.4.320.0060.00016.83
7.4.300.0000.00616.66
7.4.290.0040.00416.73
7.4.280.0040.00416.76
7.4.270.0030.00316.73
7.4.260.0000.00816.75
7.4.250.0040.00416.79
7.4.240.0030.00516.72
7.4.230.0030.00316.91
7.4.220.0050.00216.75
7.4.210.0090.00916.66
7.4.200.0000.00716.90
7.4.140.0170.00417.86
7.4.130.0080.01316.71
7.4.120.0130.00716.73
7.4.110.0100.00916.69
7.4.100.0120.00816.73
7.4.90.0120.00716.72
7.4.80.0080.01018.06
7.4.70.0070.01116.75
7.4.60.0090.00816.63
7.4.50.0050.01316.69
7.4.40.0060.01216.65
7.4.30.0110.00816.59
7.4.20.0240.00316.63
7.4.10.0100.00916.69
7.4.00.0100.00816.65
7.3.330.0020.00515.99
7.3.320.0030.00312.92
7.3.310.0000.00716.17
7.3.300.0070.00016.16
7.3.290.0100.00616.13
7.3.280.0110.00416.13
7.3.260.0100.00716.44
7.3.250.0150.00616.20
7.3.240.0100.01016.32
7.3.230.0130.00716.13
7.3.220.0120.00616.23
7.3.210.0110.00716.29
7.3.200.0090.00816.34
7.3.190.0120.00916.33
7.3.180.0100.01016.25
7.3.170.0120.01016.15
7.3.160.0140.00616.21
7.3.150.0140.01016.23
7.3.140.0070.01116.24
7.3.130.0140.00316.21
7.3.120.0060.01016.16
7.3.110.0070.01016.26
7.3.100.0130.00416.26
7.3.90.0130.00616.17
7.3.80.0070.01316.32
7.3.70.0130.00616.17
7.3.60.0100.00716.19
7.3.50.0100.00916.09
7.3.40.0100.01116.18
7.3.30.0110.00916.14
7.3.20.0120.00516.11
7.3.10.0130.00516.14
7.3.00.0100.01016.14
7.2.340.0240.01016.62
7.2.330.0140.01016.41
7.2.320.0210.00316.42
7.2.310.0180.00816.22
7.2.300.0190.01116.31
7.2.290.0180.01016.35
7.2.280.0370.00616.37
7.2.270.0170.01716.48
7.2.260.0200.00416.54
7.2.250.0170.00716.53
7.2.240.0120.01216.32
7.2.230.0170.00816.30
7.2.220.0140.01216.39
7.2.210.0150.00616.27
7.2.200.0160.00416.36
7.2.190.0120.01116.35
7.2.180.0130.00816.29
7.2.170.0180.00716.29
7.2.160.0100.01116.31
7.2.150.0150.00716.34
7.2.140.0210.00916.33
7.2.130.0150.01116.21
7.2.120.0140.00716.22
7.2.110.0140.00616.24
7.2.100.0150.01216.31
7.2.90.0100.01416.36
7.2.80.0160.00716.46
7.2.70.0170.00616.33
7.2.60.0180.00816.25
7.2.50.0140.01316.40
7.2.40.0160.01316.46
7.2.30.0190.00816.44
7.2.20.0220.00616.38
7.2.10.0200.00816.32
7.2.00.0170.00916.34

preferences:
65.57 ms | 400 KiB | 5 Q