3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 { if ($from=="Name") { echo "wfoo";} $output[$to] = $input[$from]; } } } return $output; } $output2 = mapArray($mapping, $input2); var_dump($output2);
based on r4nqM

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.3.10.0100.00316.59
7.3.00.0040.01116.86
7.2.130.0070.00717.08
7.2.120.0110.00417.01
7.2.110.0070.00716.69
7.2.100.0120.00016.77
7.2.90.0040.00816.89
7.2.80.0080.00416.84
7.2.70.0060.01017.09
7.2.60.0030.00917.03
7.2.50.0110.00416.93
7.2.40.0060.00616.95
7.2.30.0060.00617.04
7.2.20.0060.00616.90
7.2.10.0100.00316.77
7.2.00.0050.00717.95
7.1.250.0080.00015.99
7.1.100.0060.00618.25
7.1.70.0030.00316.93
7.1.60.0870.00733.24
7.1.50.0530.01733.09
7.1.40.0430.01732.72
7.1.30.0670.01332.62
7.1.20.1030.01032.54
7.1.10.0270.01314.58
7.1.00.0130.00715.01
7.0.200.0530.01014.89
7.0.190.0470.01314.83
7.0.180.0400.01014.64
7.0.170.0570.00714.58
7.0.160.0330.01014.40
7.0.150.0570.00714.58
7.0.140.0400.00714.54
7.0.130.0130.01014.70
7.0.120.0070.01314.76
7.0.110.0430.00314.30
7.0.100.0500.01314.43
7.0.90.0600.00014.29
7.0.80.0030.01014.77
7.0.70.0000.01314.46
7.0.60.0000.02014.25
7.0.50.0330.01314.62
7.0.40.0530.01714.87
7.0.30.0500.00714.63
7.0.20.0130.01014.71
7.0.10.0370.01014.77
7.0.00.0300.02014.62
hhvm-3.15.40.0570.18385.43
5.6.300.0070.07320.93
5.6.290.0270.06020.61
5.6.280.0170.07720.80
5.6.270.0230.06020.87
5.6.260.0230.05720.77
5.6.250.0100.07720.77
5.6.240.0100.06020.72
5.6.230.0070.06320.84
5.6.220.0070.06320.89
5.6.210.0170.07020.58
5.6.200.0200.05720.93
5.6.190.0100.06020.71
5.6.180.0070.05720.92
5.6.170.0130.05320.94
5.6.160.0100.08020.72
5.6.150.0130.07020.82
5.6.140.0200.07320.84
5.6.130.0130.07020.98
5.6.120.0070.06720.94
5.6.110.0100.06720.86
5.6.100.0070.06720.68
5.6.90.0200.05020.96
5.6.80.0100.07720.26
5.6.70.0130.06320.36
5.6.60.0100.07320.10
5.6.50.0100.05720.33
5.6.40.0100.07020.18
5.6.30.0100.07720.18
5.6.20.0170.04720.07
5.6.10.0200.06020.07
5.6.00.0130.06320.09