3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mapping = [ "AccountId" => "id", "Street" => "street_name", "Country" => "country", "Contacts" => "contacts", "Id" => "contact_id", "Name" => "name" ]; $input2 = [ "AccountId" => "18", "Street" => "Some Street 123", "Country" => "England", "Contacts" => [ [ "Id" => "1234", "Name" => "John Doe" ] ] ]; function mapArray($mapping, $input) { $output = []; foreach ($mapping as $from => $to) { if (array_key_exists($from, $input)) { if (is_array($input[$from])) { $output[$to] = mapArray($mapping, $input[$from]); } else { $output[$to] = $input[$from]; } } } return $output; } $output2 = mapArray($mapping, $input2); var_dump($output2);

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.0030.01416.63
8.3.50.0140.00716.72
8.3.40.0140.00018.55
8.3.30.0090.00618.64
8.3.20.0050.00220.21
8.3.10.0080.00021.73
8.3.00.0080.00020.80
8.2.180.0070.00718.04
8.2.170.0090.01222.96
8.2.160.0040.01121.88
8.2.150.0080.00024.18
8.2.140.0070.00024.66
8.2.130.0090.00022.33
8.2.120.0040.00426.35
8.2.110.0030.00720.35
8.2.100.0090.00317.84
8.2.90.0040.00419.40
8.2.80.0040.00418.04
8.2.70.0050.00317.63
8.2.60.0000.00718.03
8.2.50.0040.00418.10
8.2.40.0060.00322.06
8.2.30.0020.00519.20
8.2.20.0000.00718.04
8.2.10.0040.00418.01
8.2.00.0070.00018.11
8.1.280.0120.00325.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00720.81
8.1.230.0080.00419.09
8.1.220.0050.00317.79
8.1.210.0090.00018.77
8.1.200.0060.00317.25
8.1.190.0040.00417.22
8.1.180.0000.00918.10
8.1.170.0080.00018.52
8.1.160.0000.00719.09
8.1.150.0070.00018.96
8.1.140.0040.00419.61
8.1.130.0030.00318.82
8.1.120.0070.00317.30
8.1.110.0040.00417.37
8.1.100.0080.00017.52
8.1.90.0040.00417.35
8.1.80.0050.00217.35
8.1.70.0000.00817.39
8.1.60.0030.00617.59
8.1.50.0040.00417.53
8.1.40.0030.00517.55
8.1.30.0080.00017.55
8.1.20.0040.00417.69
8.1.10.0040.00417.41
8.1.00.0040.00417.52
8.0.300.0040.00418.77
8.0.290.0040.00416.63
8.0.280.0030.00318.42
8.0.270.0000.00716.85
8.0.260.0000.00816.84
8.0.250.0000.00716.93
8.0.240.0000.00716.75
8.0.230.0040.00416.99
8.0.220.0070.00016.78
8.0.210.0070.00016.90
8.0.200.0030.00316.82
8.0.190.0000.00816.83
8.0.180.0060.00316.95
8.0.170.0040.00316.91
8.0.160.0050.00216.91
8.0.150.0030.00316.90
8.0.140.0000.00716.88
8.0.130.0050.00213.26
8.0.120.0000.00716.84
8.0.110.0000.00716.92
8.0.100.0040.00416.89
8.0.90.0040.00416.80
8.0.80.0120.00616.87
8.0.70.0050.00216.79
8.0.60.0000.00716.73
8.0.50.0050.00316.93
8.0.30.0110.00817.01
8.0.20.0130.00717.40
8.0.10.0030.00516.83
8.0.00.0110.00916.73
7.4.330.0020.00215.55
7.4.320.0000.00716.54
7.4.300.0020.00516.61
7.4.290.0120.00016.50
7.4.280.0030.00516.52
7.4.270.0000.00816.38
7.4.260.0000.00716.60
7.4.250.0000.00716.56
7.4.240.0070.00016.63
7.4.230.0030.00316.61
7.4.220.0180.00916.57
7.4.210.0000.01416.65
7.4.200.0040.00416.36
7.4.160.0070.00916.43
7.4.150.0080.01117.40
7.4.140.0070.01217.86
7.4.130.0150.01016.50
7.4.120.0110.00916.56
7.4.110.0100.00716.71
7.4.100.0030.01416.64
7.4.90.0090.00916.34
7.4.80.0040.01319.39
7.4.70.0030.01316.56
7.4.60.0080.00816.32
7.4.50.0040.00816.55
7.4.40.0060.01116.33
7.4.30.0040.01216.68
7.4.00.0070.01214.88
7.3.330.0000.00713.32
7.3.320.0030.00313.17
7.3.310.0070.00016.35
7.3.300.0000.00716.35
7.3.290.0080.00816.31
7.3.280.0080.00916.31
7.3.270.0100.01317.40
7.3.260.0130.00716.42
7.3.250.0140.00616.41
7.3.240.0090.00916.50
7.3.230.0130.00316.37
7.3.210.0040.01416.39
7.3.200.0100.00716.31
7.3.190.0080.00816.44
7.3.180.0120.00316.41
7.3.170.0080.00816.54
7.3.160.0060.00916.37
7.3.120.0080.00814.82
7.3.110.0040.01414.75
7.3.100.0100.01014.60
7.3.90.0070.01014.57
7.3.80.0100.00714.87
7.3.70.0040.00814.91
7.3.60.0000.01615.00
7.3.50.0080.00614.71
7.3.40.0100.00314.88
7.3.30.0100.00314.73
7.3.20.0030.01016.71
7.3.10.0060.01016.69
7.3.00.0040.00816.88
7.2.330.0080.01116.50
7.2.320.0120.00616.81
7.2.310.0060.01116.69
7.2.300.0090.00916.69
7.2.290.0160.02516.45
7.2.250.0070.01314.98
7.2.240.0030.01315.13
7.2.230.0120.00615.25
7.2.220.0030.01014.84
7.2.210.0080.00815.11
7.2.200.0040.00815.25
7.2.190.0030.01014.96
7.2.180.0120.00315.18
7.2.170.0040.01115.04
7.2.130.0030.00917.07
7.2.120.0030.00616.91
7.2.110.0080.00316.70
7.2.100.0040.00816.84
7.2.90.0090.00016.96
7.2.80.0000.01817.05
7.2.70.0130.00017.06
7.2.60.0000.01516.96
7.2.50.0040.01116.91
7.2.40.0070.00717.11
7.2.30.0070.00716.86
7.2.20.0070.00317.01
7.2.10.0000.01117.00
7.2.00.0020.01418.07
7.1.330.0110.00415.60
7.1.320.0030.01015.75
7.1.310.0100.00615.99
7.1.300.0090.00315.78
7.1.290.0030.00915.89
7.1.280.0030.00916.04
7.1.270.0080.00815.59
7.1.260.0070.01015.86
7.1.250.0000.01315.62
7.1.200.0060.00615.91
7.1.100.0040.01417.91
7.1.70.0040.00417.34
7.1.60.0270.02033.10
7.1.50.0400.00733.09
7.1.40.0400.00732.81
7.1.30.0400.01032.47
7.1.20.0270.02332.80
7.1.10.0330.01014.75
7.1.00.0270.00714.88
7.0.200.0230.00715.06
7.0.190.0130.01714.84
7.0.180.0300.01014.55
7.0.170.0300.00314.26
7.0.160.0270.00714.49
7.0.150.0300.00314.54
7.0.140.0930.01714.62
7.0.130.0230.01314.79
7.0.120.0230.01014.50
7.0.110.0200.01314.47
7.0.100.0230.01014.54
7.0.90.0270.00714.55
7.0.80.0230.01014.49
7.0.70.0370.01014.55
7.0.60.0230.01014.39
7.0.50.0300.00314.47
7.0.40.0300.00714.60
7.0.30.0300.00714.69
7.0.20.0200.01314.55
7.0.10.0230.01014.67
7.0.00.0270.00714.48

preferences:
46.49 ms | 400 KiB | 5 Q