3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = [ [ "sender" => "userA", "value" => 10, "function" => "deposit" ], [ "sender" => "userB", "value" => 5, "function" => "deposit" ], [ "sender" => "userA", "value" => 2, "function" => "withdraw" ], [ "sender" => "userA", "value" => 3, "function" => "deposit" ], [ "sender" => "userA", "value" => 20, "function" => "deposit" ], [ "sender" => "userC", "value" => 99, "function" => "withdraw" ] ]; $result = array_reduce($arrays, function ($acc, $curr) { if (array_key_exists($curr["sender"], $acc)) { if ($curr["function"] === "deposit") { $acc[$curr["sender"]] += $curr["value"]; } if ($curr["function"] === "withdraw") { $acc[$curr["sender"]] -= $curr["value"]; } } else { if ($curr["function"] === "deposit") { $acc[$curr["sender"]] = $curr["value"]; } if ($curr["function"] === "withdraw") { $acc[$curr["sender"]] = -1 * $curr["value"]; } } return $acc; }, []); print_r($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.4.140.0150.00617.56
8.4.130.0100.00917.91
8.4.120.0050.00520.44
8.4.110.0110.00920.36
8.4.100.0160.00517.78
8.4.90.0110.01018.69
8.4.80.0090.01117.69
8.4.70.0140.00717.81
8.4.60.0120.00718.61
8.4.50.0060.00421.30
8.4.40.0040.00717.80
8.4.30.0130.00720.50
8.4.20.0160.00319.69
8.4.10.0040.01517.68
8.3.270.0100.00916.70
8.3.260.0110.00916.68
8.3.250.0130.00518.70
8.3.240.0150.00616.71
8.3.230.0100.00916.52
8.3.220.0090.00917.17
8.3.210.0090.00716.51
8.3.200.0070.00316.53
8.3.190.0160.00417.32
8.3.180.0100.00916.55
8.3.170.0100.01016.66
8.3.160.0160.00316.50
8.3.150.0110.00717.16
8.3.140.0120.00616.70
8.3.130.0160.00318.40
8.3.120.0060.00918.86
8.3.110.0030.01620.94
8.3.100.0070.00024.06
8.3.90.0070.00726.77
8.3.80.0060.00316.75
8.3.70.0070.01118.30
8.3.60.0140.00316.63
8.3.50.0090.00618.41
8.3.40.0130.00720.14
8.3.30.0120.00318.71
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0070.00326.16
8.2.290.0110.00822.31
8.2.280.0100.00818.24
8.2.270.0100.01019.20
8.2.260.0120.00618.65
8.2.250.0200.00016.42
8.2.240.0060.00317.57
8.2.230.0000.00822.58
8.2.220.0040.00437.54
8.2.210.0000.00826.77
8.2.200.0030.00616.88
8.2.190.0130.00716.58
8.2.180.0070.00725.92
8.2.170.0060.00918.91
8.2.160.0070.00722.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00426.16
8.2.110.0040.00422.00
8.2.100.0030.00917.84
8.2.90.0040.00417.91
8.2.80.0040.00418.16
8.2.70.0000.00818.04
8.2.60.0000.01018.22
8.2.50.0040.00418.10
8.2.40.0040.00420.78
8.2.30.0040.00419.29
8.2.20.0040.00420.38
8.2.10.0030.00517.80
8.2.00.0000.00719.29
8.1.330.0110.00621.83
8.1.320.0150.00516.18
8.1.310.0180.00016.77
8.1.300.0030.00616.30
8.1.290.0030.00618.88
8.1.280.0110.00725.92
8.1.270.0070.00023.99
8.1.260.0100.00726.35
8.1.250.0000.00728.09
8.1.240.0080.00317.48
8.1.230.0110.00022.71
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0000.01017.23
8.1.190.0080.00017.38
8.1.180.0040.00418.10
8.1.170.0060.00318.64
8.1.160.0000.00818.90
8.1.150.0070.00018.70
8.1.140.0000.00817.52
8.1.130.0030.00617.53
8.1.120.0050.00517.49
8.1.110.0040.00417.45
8.1.100.0040.00417.42
8.1.90.0050.00217.38
8.1.80.0000.00917.38
8.1.70.0000.00717.46
8.1.60.0100.00017.60
8.1.50.0000.00817.58
8.1.40.0040.00417.50
8.1.30.0040.00417.66
8.1.20.0040.00417.62
8.1.10.0040.00417.52
8.1.00.0040.00417.45
8.0.300.0000.00720.20
8.0.290.0000.00816.75
8.0.280.0040.00418.55
8.0.270.0030.00416.73
8.0.260.0060.00316.76
8.0.250.0030.00316.97
8.0.240.0080.00016.98
8.0.230.0000.00816.79
8.0.220.0030.00716.82
8.0.210.0000.00716.81
8.0.200.0030.00316.96
8.0.190.0030.00716.95
8.0.180.0050.00516.90
8.0.170.0090.00016.98
8.0.160.0030.00516.90
8.0.150.0000.00716.86
8.0.140.0070.00016.70
8.0.130.0000.00816.90
8.0.120.0070.00016.90
8.0.110.0050.00216.80
8.0.100.0000.00716.90
8.0.90.0000.00716.96
8.0.80.0000.00716.88
8.0.70.0040.00416.91
8.0.60.0000.00716.91
8.0.50.0000.00716.89
8.0.30.0050.00216.71
8.0.20.0000.00716.86
8.0.10.0040.00416.98
7.4.330.0020.00215.55
7.4.320.0030.00316.51
7.4.300.0040.00416.57
7.4.290.0050.00316.32
7.4.280.0070.00316.51
7.4.270.0030.00316.41
7.4.260.0030.00316.56
7.4.250.0070.00016.48
7.4.240.0030.00316.61
7.4.230.0000.00716.47
7.4.220.0030.00316.60
7.4.210.0030.00316.48
7.4.200.0000.00716.46
7.4.190.0020.00516.54
7.4.180.0000.00816.54
7.4.160.0030.00316.59
7.4.150.0030.00316.37
7.4.140.0080.00016.27
7.4.130.0000.00716.42
7.4.120.0070.00016.48
7.4.110.0030.00316.33
7.4.100.0030.00316.50
7.4.90.0040.00416.29
7.4.80.0000.00816.36
7.4.70.0000.00716.22
7.4.60.0030.00316.47
7.4.50.0070.00016.38
7.4.40.0030.00316.37
7.4.30.0070.00016.48
7.4.20.0000.00716.41
7.4.10.0030.00316.32
7.4.00.0030.00616.30

preferences:
36.27 ms | 403 KiB | 5 Q