3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "one" => ["id" => 111, "name" => "Jhon"], "two" => ["id" => 222, "name" => "Adam"], "three" => ["id" => 111, "name" => "Mark"], "four" => ["id" => 125, "name" => "Jhon"], "five" => ["id" => 111, "name" => "Jhon"], "six" => ["id" => 222, "name" => "Rock"], ]; // store added IDs $added = []; // filter array (need to pass $added as reference to be updated) $output = array_filter($array, function($item) use (&$added) { // shortcut for readability $id = $item['id']; // Check if id already exists if (isset($added[$id])) { return false; } // add to reference $added[$id] = true; // add to final array return true; }); unset($added); // no longer needed. var_dump($output);

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.130.0050.00319.25
8.4.120.0100.00922.34
8.4.110.0100.00918.92
8.4.100.0040.00518.79
8.4.90.0100.00618.68
8.4.80.0130.00717.91
8.4.70.0090.00717.96
8.4.60.0150.00620.52
8.4.50.0120.00723.95
8.4.40.0080.01217.69
8.4.30.0050.00520.40
8.4.20.0130.01017.75
8.4.10.0030.00617.83
8.3.250.0090.01119.10
8.3.240.0090.00916.52
8.3.230.0110.00816.80
8.3.220.0100.00618.95
8.3.210.0090.00118.51
8.3.200.0100.00716.36
8.3.190.0090.00916.61
8.3.180.0060.00316.60
8.3.170.0120.00318.62
8.3.160.0060.01218.79
8.3.150.0090.00918.33
8.3.140.0140.00417.18
8.3.130.0060.00318.36
8.3.120.0070.00720.61
8.3.110.0070.00316.42
8.3.100.0030.00616.66
8.3.90.0050.00326.77
8.3.80.0030.00616.75
8.3.70.0140.00716.88
8.3.60.0180.00016.63
8.3.50.0100.00718.11
8.3.40.0120.00318.80
8.3.30.0090.00618.57
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0050.00326.16
8.2.290.0140.00620.46
8.2.280.0170.00320.20
8.2.270.0140.00317.38
8.2.260.0040.00416.55
8.2.250.0000.00816.61
8.2.240.0060.00318.87
8.2.230.0000.00920.94
8.2.220.0050.00324.06
8.2.210.0070.00726.77
8.2.200.0060.00318.16
8.2.190.0100.01016.63
8.2.180.0120.00625.92
8.2.170.0110.00419.08
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0050.00226.16
8.2.120.0040.00419.72
8.2.110.0070.00322.07
8.2.100.0080.00417.97
8.2.90.0080.00017.86
8.2.80.0060.00317.97
8.2.70.0040.00417.63
8.2.60.0090.00018.03
8.2.50.0030.00618.07
8.2.40.0090.00018.34
8.2.30.0070.00018.11
8.2.20.0030.00618.01
8.2.10.0000.00819.37
8.2.00.0000.00719.32
8.1.330.0090.01121.81
8.1.320.0110.00716.14
8.1.310.0050.00318.70
8.1.300.0060.00319.92
8.1.290.0030.00630.84
8.1.280.0070.01125.92
8.1.270.0070.00024.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00622.54
8.1.230.0060.00620.96
8.1.220.0080.00017.79
8.1.210.0080.00518.89
8.1.200.0060.00617.48
8.1.190.0040.00417.38
8.1.180.0000.00818.10
8.1.170.0000.00818.61
8.1.160.0000.00718.89
8.1.150.0030.00618.79
8.1.140.0040.00418.77
8.1.130.0030.00320.20
8.1.120.0050.00217.46
8.1.110.0060.00317.50
8.1.100.0060.00317.43
8.1.90.0050.00317.36
8.1.80.0050.00617.50
8.1.70.0000.00717.50
8.1.60.0040.00417.48
8.1.50.0030.00517.59
8.1.40.0000.00717.41
8.1.30.0050.00517.55
8.1.20.0040.00417.68
8.1.10.0040.00417.59
8.1.00.0030.00517.52
8.0.300.0040.00419.98
8.0.290.0070.00016.63
8.0.280.0000.00718.45
8.0.270.0000.00718.00
8.0.260.0030.00318.36
8.0.250.0070.00017.00
8.0.240.0030.00316.87
8.0.230.0050.00216.98
8.0.220.0070.00016.89
8.0.210.0030.00316.91
8.0.200.0040.00417.00
8.0.190.0000.00716.95
8.0.180.0090.00016.96
8.0.170.0060.00316.78
8.0.160.0030.00616.89
8.0.150.0000.00816.84
8.0.140.0040.00416.91
8.0.130.0030.00313.28
8.0.120.0080.00016.96
8.0.110.0040.00416.91
8.0.100.0040.00416.93
8.0.90.0000.00716.86
8.0.80.0080.00816.89
8.0.70.0030.00516.76
8.0.60.0080.00016.77
8.0.50.0000.00716.80
8.0.30.0030.01416.93
8.0.20.0060.01116.99
8.0.10.0110.00417.00
8.0.00.0110.00517.05
7.4.330.0090.00015.55
7.4.320.0060.00016.65
7.4.300.0030.00316.51
7.4.290.0040.00416.42
7.4.280.0040.00416.61
7.4.270.0000.00816.62
7.4.260.0050.00013.28
7.4.250.0030.00316.61
7.4.240.0060.00116.49
7.4.230.0080.00016.30
7.4.220.0030.00316.64
7.4.210.0080.00916.67
7.4.200.0000.00816.60
7.4.160.0040.01316.54
7.4.150.0040.01216.54
7.4.140.0070.01416.39
7.4.130.0030.01016.41
7.4.120.0140.00616.33
7.4.110.0060.00916.44
7.4.100.0070.01016.43
7.4.90.0150.00616.41
7.4.80.0100.01016.62
7.4.70.0030.01416.56
7.4.60.0080.01216.55
7.4.50.0000.01416.41
7.4.40.0090.00616.39
7.4.30.0000.01516.55
7.4.20.0030.01016.41
7.4.10.0040.01516.54
7.4.00.0140.00316.46
7.3.330.0070.00016.24
7.3.320.0060.00013.14
7.3.310.0040.00416.21
7.3.300.0070.00016.32
7.3.290.0070.01316.41
7.3.270.0150.00016.36
7.3.260.0100.01016.25
7.3.250.0080.00616.26
7.3.240.0070.00716.28
7.3.230.0000.01416.24
7.3.220.0050.01416.32
7.3.210.0100.01016.32
7.3.200.0150.00416.29
7.3.190.0060.00916.21
7.3.180.0080.00816.30
7.3.170.0040.01016.35
7.3.160.0070.00716.25
7.3.150.0090.00816.31
7.3.140.0100.00716.29
7.3.130.0040.01216.20
7.3.120.0080.00816.17
7.3.110.0070.00716.15
7.3.100.0030.01416.21
7.3.90.0110.00416.51
7.3.80.0110.00316.30
7.3.70.0080.00516.41
7.3.60.0070.00616.42
7.3.50.0050.01016.47
7.3.40.0050.00816.43
7.3.30.0060.01216.46
7.3.20.0040.01516.47
7.3.10.0130.00616.41
7.3.00.0030.01516.44

preferences:
34.05 ms | 403 KiB | 5 Q