3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_list= array("Jan 2016"=>2, "Feb 2016"=>4, "Mar 2016"=>2,"Apr 2016"=>0, "Jan 2017"=>9,"Feb 2017"=>2,"Mar 2017"=>5,"Jan 2018"=>4,"Feb 2018"=>6); $start = microtime(1); $array = array(); foreach($array_list as $key => $value): $MonthYear_label = explode(" ",$key); $year_label = $MonthYear_label[1]; $month_label = $MonthYear_label[0]; $curr_year = $year_label; $array[$curr_year]['count'] = $array[$curr_year]['count'] + $value; endforeach; echo (microtime(1)-$start)*1000 . "\n"; $start = microtime(1); foreach(array_keys($array_list) as $key){ $years[] = explode(" ", $key)[1]; } foreach(array_unique($years) as $year){ $res[$year] = array_sum(array_intersect_key(array_values($array_list), array_intersect($years, [$year]))); } echo (microtime(1)-$start)*1000 . "\n";

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.1.220.0130.00618.77
7.4.10.0090.00616.00
7.4.00.0110.00716.00
7.3.130.0070.01116.00
7.3.120.0040.01116.00
7.3.110.0170.00016.00
7.3.100.0040.01116.00
7.3.90.0030.01116.00
7.3.80.0120.00316.00
7.3.70.0120.00316.00
7.3.60.0050.00516.00
7.3.50.0100.00316.00
7.3.40.0040.00816.00
7.3.30.0060.00916.00
7.3.20.0000.01616.86
7.3.10.0060.00916.73
7.3.00.0020.01116.74
7.2.260.0070.01016.00
7.2.250.0100.00616.00
7.2.240.0040.01516.00
7.2.230.0080.00316.00
7.2.220.0040.01116.00
7.2.210.0090.00616.00
7.2.200.0090.00016.00
7.2.190.0040.01416.00
7.2.180.0080.00816.00
7.2.170.0060.00916.00
7.2.160.0000.01516.00
7.2.150.0060.00316.77
7.2.140.0040.01117.09
7.2.130.0050.01017.02
7.2.120.0050.01217.05
7.2.110.0070.00516.90
7.2.100.0070.00917.11
7.2.90.0060.00916.87
7.2.80.0090.00417.01
7.2.70.0060.00916.82
7.2.60.0110.00616.90
7.2.50.0030.01216.96
7.2.40.1950.01017.38
7.2.30.1260.00617.11
7.2.20.1160.00917.25
7.2.10.1130.00817.25
7.2.00.1100.00517.26
7.1.330.0000.01216.00
7.1.320.0030.01416.00
7.1.310.0100.00616.00
7.1.300.0070.00716.00
7.1.290.0000.00916.00
7.1.280.0130.00316.00
7.1.270.0040.01116.00
7.1.260.0030.01016.00
7.1.250.0090.00515.96
7.1.240.0000.01416.00
7.1.230.0070.00716.00
7.1.220.0090.00616.00
7.1.210.0000.01216.00
7.1.200.0100.00316.00
7.1.190.0040.01416.00
7.1.180.0000.01116.00
7.1.170.0060.00916.00
7.1.160.2180.01116.45
7.1.150.1960.01016.45
7.1.140.1590.00716.40
7.1.130.2280.00816.47
7.1.120.1450.00716.48
7.1.110.1580.00816.19
7.1.100.1450.00716.17
7.1.90.0100.00816.07
7.1.80.1740.00716.16
7.1.70.1730.00715.76
7.1.60.2110.00824.67
7.1.50.2580.01124.37
7.1.40.2410.00724.28
7.1.30.0180.01024.37
7.1.20.1350.00624.40
7.1.10.2180.01015.34
7.1.00.0270.00715.46
7.0.330.0090.00616.00
7.0.320.0060.00616.00
7.0.310.0070.00716.00
7.0.300.0030.01216.00
7.0.290.0030.01016.00
7.0.280.0030.01016.00
7.0.270.0110.00416.00
7.0.260.0040.01116.00
7.0.250.0000.00916.00
7.0.240.0100.00316.00
7.0.230.0040.00816.00
7.0.220.0060.00616.00
7.0.210.0030.00916.00
7.0.200.0030.01316.00
7.0.190.0030.01016.00
7.0.180.0060.00616.00
7.0.170.0030.01016.00
7.0.160.0000.00816.00
7.0.150.0070.00716.00
7.0.140.0040.01116.00
7.0.130.0060.00916.00
7.0.120.0060.00616.00
7.0.110.0000.01416.00
7.0.100.0030.01016.00
7.0.90.0070.01016.00
7.0.80.0040.00416.00
7.0.70.0000.01616.00
7.0.60.0080.00816.00
7.0.50.0040.01116.00
7.0.40.0060.00616.00
7.0.30.0070.01016.00
7.0.20.0070.00716.00
7.0.10.0090.00916.00
7.0.00.0080.00416.00
5.6.400.0030.01216.00
5.6.390.0060.00916.00
5.6.380.0030.01016.00
5.6.370.0130.00016.00
5.6.360.0090.00916.00
5.6.350.0100.00716.00
5.6.340.0030.01016.00
5.6.330.0030.00616.00
5.6.320.0030.00916.00
5.6.310.0080.00016.00
5.6.300.0000.01816.00
5.6.290.0030.01016.00
5.6.280.0070.00716.00
5.6.270.0070.00716.00
5.6.260.0100.00316.00
5.6.250.0070.01016.00
5.6.240.0070.00716.00
5.6.230.0070.00716.00
5.6.220.0030.00716.00
5.6.210.0000.01116.00
5.6.200.0070.01016.00
5.6.190.0030.01016.00
5.6.180.0030.01416.00
5.6.170.0030.01316.00
5.6.160.0000.01216.00
5.6.150.0060.01216.00
5.6.140.0100.00316.00
5.6.130.0100.00316.00
5.6.120.0030.01016.00
5.6.110.0090.00016.00
5.6.100.0030.01016.00
5.6.90.0000.01116.00
5.6.80.0000.01416.00
5.6.70.0030.01016.00
5.6.60.0070.00716.00
5.6.50.0000.01416.00
5.6.40.0100.00716.00
5.6.30.0040.01216.00
5.6.20.0060.01016.00
5.6.10.0000.02016.00
5.6.00.0070.01316.00
5.5.380.0090.00118.77

preferences:
41.99 ms | 403 KiB | 5 Q