3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 0=>array( 'date'=>'2017-09-01', 'total'=>4 ), 1=>array( 'date'=>'2017-09-07', 'total'=>6 ), 2=>array( 'date'=>'2017-09-12', 'total'=>6 ), 3=>array( 'date'=>'2017-09-14', 'total'=>6 ) ); // array with only dates to search in $dates = array_column($arr, "date"); // Create an array with all dates from first item to last item $start = new DateTime($arr[0]["date"]); $end = new DateTime(end($arr)["date"]); $range = new DatePeriod($start, new DateInterval('P1D'), $end); // $range is now all dates from start to end minus last one. // Loop through the range foreach($range as $date){ //See if the current date exist is first array $find = array_search($date->format("Y-m-d"), $dates); If($find !== false){ $result[] = $arr[$find]; // if it does copy it to result array }Else{ // If not add it and create a total = 0 $result[] = array('date' => $date->format("Y-m-d"), 'total' => 0); } } // Since the loop does not loop all dates we need to add the last item to result. $result[] = end($arr); Var_dump($result);

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.5.10.0100.00816.75
8.5.00.0130.00920.17
8.4.160.0100.01124.07
8.4.150.0010.00114.05
8.4.140.0100.01117.65
8.4.130.0130.00818.03
8.4.120.0160.00520.50
8.4.110.0090.01122.31
8.4.100.0140.00918.03
8.4.90.0060.00419.00
8.4.80.0130.00718.14
8.4.70.0130.00717.83
8.4.60.0060.01118.78
8.4.50.0120.00619.63
8.4.40.0100.00619.61
8.4.30.0070.01119.55
8.4.20.0190.00317.64
8.4.10.0040.00719.55
8.3.280.0100.01118.64
8.3.270.0100.01016.92
8.3.260.0100.01016.70
8.3.250.0110.00819.09
8.3.240.0130.00516.84
8.3.230.0110.00916.94
8.3.220.0060.00317.29
8.3.210.0100.00616.68
8.3.200.0130.00816.88
8.3.190.0070.00817.18
8.3.180.0120.00516.84
8.3.170.0110.00718.85
8.3.160.0040.00418.41
8.3.150.0090.00920.74
8.3.140.0070.01117.23
8.3.130.0090.00018.77
8.3.120.0050.00518.87
8.3.110.0080.00420.94
8.3.100.0060.00324.06
8.3.90.0050.00326.77
8.3.80.0060.00316.50
8.3.70.0150.00018.68
8.3.60.0070.01516.75
8.3.50.0110.00617.47
8.3.40.0120.00319.08
8.3.30.0080.00818.71
8.3.20.0040.00422.08
8.3.10.0080.00021.95
8.3.00.0050.00323.48
8.2.290.0080.00320.59
8.2.280.0050.00418.23
8.2.270.0040.01617.54
8.2.260.0090.00619.15
8.2.250.0000.01518.53
8.2.240.0000.00918.96
8.2.230.0090.00022.58
8.2.220.0080.00037.54
8.2.210.0040.00426.77
8.2.200.0060.00318.66
8.2.190.0100.01016.63
8.2.180.0150.00618.54
8.2.170.0090.00922.96
8.2.160.0110.00322.04
8.2.150.0030.00625.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0090.00921.12
8.2.110.0030.00620.52
8.2.100.0100.00717.97
8.2.90.0040.00417.88
8.2.80.0050.00318.74
8.2.70.0060.00317.88
8.2.60.0080.00017.75
8.2.50.0000.00917.88
8.2.40.0000.00819.72
8.2.30.0000.00819.32
8.2.20.0000.01118.24
8.2.10.0030.00618.32
8.2.00.0040.00418.23
8.1.330.0090.00922.19
8.1.320.0130.00620.05
8.1.310.0040.00416.98
8.1.300.0070.01316.34
8.1.290.0030.00630.84
8.1.280.0040.01125.92
8.1.270.0060.00322.18
8.1.260.0080.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00323.86
8.1.230.0110.00019.04
8.1.220.0080.00017.77
8.1.210.0000.00818.77
8.1.200.0030.00617.60
8.1.190.0060.00317.48
8.1.180.0060.00618.10
8.1.170.0000.00817.75
8.1.160.0070.00018.89
8.1.150.0000.00820.15
8.1.140.0000.00819.69
8.1.130.0040.00420.61
8.1.120.0000.00817.54
8.1.110.0000.00817.57
8.1.100.0040.00417.63
8.1.90.0000.00817.59
8.1.80.0000.00717.72
8.1.70.0070.00017.63
8.1.60.0040.00417.78
8.1.50.0080.00017.68
8.1.40.0040.00417.66
8.1.30.0030.00517.76
8.1.20.0040.00417.69
8.1.10.0040.00417.69
8.1.00.0040.00417.77
8.0.300.0000.00818.77
8.0.290.0050.00216.75
8.0.280.0000.00718.45
8.0.270.0040.00417.28
8.0.260.0070.00018.57
8.0.250.0030.00317.18
8.0.240.0080.00017.09
8.0.230.0070.00017.20
8.0.220.0060.00317.02
8.0.210.0050.00316.96
8.0.200.0000.01117.09
8.0.190.0040.00417.04
8.0.180.0080.00417.09
8.0.170.0050.00317.15
8.0.160.0000.00717.16
8.0.150.0060.00317.11
8.0.140.0040.00417.00
8.0.130.0030.00313.53
8.0.120.0000.00817.05
8.0.110.0070.00017.11
8.0.100.0020.00516.98
8.0.90.0050.00316.98
8.0.80.0090.00616.99
8.0.70.0040.00416.91
8.0.60.0040.00417.08
8.0.50.0050.00217.19
8.0.30.0170.00817.28
8.0.20.0150.01217.40
8.0.10.0080.00017.34
8.0.00.0070.01116.98
7.4.330.0030.00315.55
7.4.320.0030.00316.60
7.4.300.0030.00316.66
7.4.290.0020.00416.55
7.4.280.0050.00216.73
7.4.270.0050.00316.73
7.4.260.0000.00816.66
7.4.250.0080.00016.52
7.4.240.0060.00316.80
7.4.230.0030.00316.71
7.4.220.0120.00616.67
7.4.210.0060.00916.85
7.4.200.0070.00016.54
7.4.160.0090.01316.80
7.4.150.0160.00317.40
7.4.140.0120.01117.86
7.4.130.0160.00416.77
7.4.120.0110.01116.69
7.4.110.0100.00916.49
7.4.100.0040.01516.78
7.4.90.0040.01516.50
7.4.80.0090.00919.39
7.4.70.0080.01616.70
7.4.60.0110.00816.74
7.4.50.0100.00316.73
7.4.40.0190.00016.83
7.4.30.0120.00616.48
7.4.00.0160.00015.07
7.3.330.0030.00313.23
7.3.320.0000.00513.34
7.3.310.0080.00016.54
7.3.300.0030.00316.38
7.3.290.0070.00916.44
7.3.280.0100.00916.50
7.3.270.0150.00317.40
7.3.260.0110.01016.57
7.3.250.0060.01316.55
7.3.240.0110.00816.59
7.3.230.0130.00616.64
7.3.210.0140.00416.57
7.3.200.0060.01216.68
7.3.190.0070.01716.59
7.3.180.0070.01016.73
7.3.170.0090.00916.55
7.3.160.0030.01416.57
7.2.330.0110.00716.92
7.2.320.0090.01516.68
7.2.310.0090.00916.70
7.2.300.0130.01316.84
7.2.290.0150.00316.98
7.2.80.0090.00616.76
7.2.60.0050.00516.99
7.1.200.0080.00416.02
7.1.90.0080.00418.33
7.1.80.0030.01118.28
7.1.70.0060.00617.49
7.1.60.0200.00635.17
7.1.50.0240.00334.98
7.1.40.0190.00834.52
7.1.30.0190.00634.64
7.1.20.0110.01534.97
7.1.10.0000.01316.73
7.1.00.0080.00416.74
7.0.230.0120.00017.80
7.0.220.0030.00918.12
7.0.210.0030.00916.79
7.0.200.0100.00317.16
7.0.190.0060.00616.68
7.0.180.0050.00816.35
7.0.170.0080.00516.53
7.0.160.0080.00416.24
7.0.150.0040.00816.28
7.0.140.0060.00616.41
7.0.130.0030.00916.70
7.0.120.0040.00816.87
7.0.110.0080.00416.41
7.0.100.0030.00916.50
7.0.90.0040.00816.66
7.0.80.0000.01316.39
7.0.70.0080.00916.67
7.0.60.0040.00816.39
7.0.50.0050.00816.37
7.0.40.0030.00916.36
7.0.30.0030.00916.50
7.0.20.0000.01316.50
7.0.10.0040.00916.50
7.0.00.0060.00616.58

preferences:
167.89 ms | 403 KiB | 5 Q