3v4l.org

run code in 300+ PHP versions simultaneously
<?php class my_obj { public $term_id; public $name; public $slug; public function __construct($i, $n, $s) { $this->term_id = $i; $this->name = $n; $this->slug = $s; } } $objA = new my_obj(23, 'Assasination', 'assasination'); $objB = new my_obj(14, 'Campaign Finance', 'campaign-finance'); $objC = new my_obj(15, 'Campaign Finance', 'campaign-finance-good-government-political-reform'); $array = array($objA, $objB, $objC); echo 'Original array:\n'; print_r($array); /** Answer Code begins here **/ // Build temporary array for array_unique $tmp = array(); foreach($array as $k => $v) $tmp[$k] = $v->name; // Find duplicates in temporary array $tmp = array_unique($tmp); // Build new array with only non-duplicate items $filtered = []; foreach($array as $k => $v) { if (array_key_exists($k, $tmp)) $filtered[$k] = $v; } /** Answer Code ends here **/ echo 'After removing duplicates\n'; print_r($filtered);

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.120.0060.00322.43
8.4.110.0060.00318.88
8.4.100.0050.00417.79
8.4.90.0120.00618.73
8.4.80.0110.01017.77
8.4.70.0120.00717.84
8.4.60.0130.00717.70
8.4.50.0140.00517.60
8.4.40.0000.00917.59
8.4.30.0110.01120.45
8.4.20.0100.01318.70
8.4.10.0030.01617.64
8.3.250.0100.00919.02
8.3.240.0110.00816.55
8.3.230.0070.00416.72
8.3.220.0090.00217.44
8.3.210.0120.00716.63
8.3.200.0100.00916.52
8.3.190.0050.01018.46
8.3.180.0100.00516.64
8.3.170.0070.00316.65
8.3.160.0040.00420.25
8.3.150.0100.01016.70
8.3.140.0000.01816.91
8.3.130.0090.00018.46
8.3.120.0100.01018.99
8.3.110.0040.00420.94
8.3.100.0110.01116.59
8.3.90.0080.00026.77
8.3.80.0060.00316.54
8.3.70.0180.00416.63
8.3.60.0100.01018.43
8.3.50.0110.00418.19
8.3.40.0100.01318.77
8.3.30.0110.00418.83
8.3.20.0000.00724.18
8.3.10.0070.00024.66
8.3.00.0080.00026.16
8.2.290.0070.00520.45
8.2.280.0060.00318.48
8.2.270.0070.01019.04
8.2.260.0110.00718.60
8.2.250.0120.00618.56
8.2.240.0000.00820.71
8.2.230.0070.00722.58
8.2.220.0090.00924.06
8.2.210.0040.01126.77
8.2.200.0090.00016.63
8.2.190.0100.01016.58
8.2.180.0110.00425.92
8.2.170.0110.01119.09
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0000.00926.16
8.2.110.0090.00020.33
8.2.100.0090.00019.18
8.1.330.0100.01022.05
8.1.320.0100.00916.19
8.1.310.0110.00718.36
8.1.300.0090.00018.22
8.1.290.0100.00030.84
8.1.280.0070.01125.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0000.01028.09
8.1.240.0060.00318.70
8.1.230.0120.00018.63
5.6.400.0150.00815.92

preferences:
27.81 ms | 403 KiB | 5 Q