3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array( 'id' => 12, '_from' => 1, '_to' => 2 ), array( 'id' => 13, '_from' => 4, '_to' => 2 ), array( 'id' => 14, '_from' => 2, '_to' => 1 ), ); $newArray = []; foreach ($array as $item) { $uniqueRecordKey = $item['_from'].'-'.$item['_to']; $oppositeRecordKey = $item['_to'].'-'.$item['_from']; //If exists record from the opposite and new ID is greater than previous put if (isset($newArray[$oppositeRecordKey])) { $newArray[$oppositeRecordKey] = $item; continue; //Do not append to the end } $newArray[$uniqueRecordKey] = $item; } var_dump($newArray);

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.0120.00820.36
8.4.110.0130.00522.11
8.4.100.0130.00717.64
8.4.90.0160.00520.46
8.4.80.0120.00819.00
8.4.70.0050.00717.62
8.4.60.0150.00518.77
8.4.50.0110.01019.38
8.4.40.0160.00319.29
8.4.30.0070.01119.40
8.4.20.0060.00320.49
8.4.10.0030.00617.63
8.3.250.0130.00619.00
8.3.240.0090.01016.74
8.3.230.0080.01416.70
8.3.220.0020.00619.05
8.3.210.0110.00916.61
8.3.200.0070.00216.69
8.3.190.0090.01017.07
8.3.180.0070.00516.54
8.3.170.0130.00418.78
8.3.160.0070.01116.48
8.3.150.0060.01220.71
8.3.140.0050.00318.97
8.3.130.0090.00018.33
8.3.120.0030.00620.55
8.3.110.0090.00920.94
8.3.100.0080.01124.06
8.3.90.0080.00026.77
8.3.80.0090.00017.97
8.3.70.0140.00416.78
8.3.60.0120.00318.27
8.3.50.0080.00618.21
8.3.40.0030.01218.67
8.3.30.0060.01018.71
8.3.20.0080.00018.79
8.3.10.0040.00423.62
8.3.00.0040.00420.74
8.2.290.0070.00520.34
8.2.280.0040.00718.25
8.2.270.0130.00616.95
8.2.260.0090.00616.48
8.2.250.0040.00416.64
8.2.240.0070.00317.07
8.2.230.0070.00422.58
8.2.220.0050.00537.54
8.2.210.0040.00426.77
8.2.200.0040.00718.41
8.2.190.0110.00416.58
8.2.180.0180.00018.07
8.2.170.0040.01122.96
8.2.160.0100.01019.32
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0030.00521.03
8.2.110.0040.00420.38
8.2.100.0000.01117.91
8.2.90.0000.00819.57
8.2.80.0080.00017.97
8.2.70.0080.00018.03
8.2.60.0050.00318.03
8.2.50.0080.00018.10
8.2.40.0000.00819.31
8.2.30.0040.00419.38
8.2.20.0030.00618.05
8.2.10.0040.00419.77
8.2.00.0030.00517.54
8.1.330.0110.00816.76
8.1.320.0150.00416.30
8.1.310.0120.00318.55
8.1.300.0080.00815.93
8.1.290.0060.00330.84
8.1.280.0090.01225.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0000.00728.09
8.1.240.0100.00319.30
8.1.230.0080.00320.91
8.1.220.0040.00417.79
8.1.210.0050.00318.97
8.1.200.0000.00917.36
8.1.190.0050.00317.00
8.1.180.0000.00818.10
8.1.170.0030.00518.57
8.1.160.0030.00518.87
8.1.150.0050.00318.89
8.1.140.0000.00723.93
8.1.130.0000.00720.20
8.1.120.0050.00217.36
8.1.110.0000.01017.41
8.1.100.0040.00417.43
8.1.90.0080.00017.33
8.1.80.0000.00817.35
8.1.70.0030.00317.39
8.1.60.0030.00617.60
8.1.50.0050.00317.45
8.1.40.0000.00817.50
8.1.30.0070.00317.63
8.1.20.0040.00417.65
8.1.10.0050.00317.41
8.1.00.0050.00317.49
8.0.300.0070.00019.42
8.0.290.0050.00516.63
8.0.280.0000.00818.46
8.0.270.0040.00417.13
8.0.260.0050.00220.22
8.0.250.0000.00716.83
8.0.240.0000.00716.95
8.0.230.0000.00716.94
8.0.220.0040.00416.78
8.0.210.0040.00416.84
8.0.200.0030.00316.96
8.0.190.0000.00816.95
8.0.180.0060.00316.92
8.0.170.0000.00916.80
8.0.160.0070.00016.84
8.0.150.0050.00316.82
8.0.140.0020.00516.85
8.0.130.0000.00613.31
8.0.120.0060.00316.90
8.0.110.0000.00716.73
8.0.100.0050.00216.68
8.0.90.0040.00416.71
8.0.80.0080.00816.87
8.0.70.0000.00716.75
8.0.60.0030.00516.85
8.0.50.0070.00016.70
8.0.30.0090.00817.16
8.0.20.0120.00717.40
8.0.10.0000.00716.88
8.0.00.0100.00916.80
7.4.330.0050.00015.55
7.4.320.0000.00616.58
7.4.300.0000.00616.43
7.4.290.0040.00416.64
7.4.280.0000.00816.57
7.4.270.0000.00716.41
7.4.260.0100.00016.53
7.4.250.0050.00316.55
7.4.240.0030.00616.51
7.4.230.0030.00516.68
7.4.220.0000.00816.70
7.4.210.0070.00916.58
7.4.200.0090.00016.39
7.4.160.0100.00916.50
7.4.140.0130.00717.86
7.4.130.0070.01516.51
7.4.120.0070.01316.57
7.4.110.0100.00816.50
7.4.100.0070.01116.48
7.4.90.0050.01516.52
7.4.80.0180.00419.39
7.4.70.0180.00316.46
7.4.60.0090.00916.35
7.4.50.0060.00916.51
7.4.40.0090.01216.63
7.4.00.0040.01115.11
7.3.330.0000.00513.26
7.3.320.0050.00013.09
7.3.310.0030.00316.38
7.3.300.0030.00316.32
7.3.290.0060.00016.17
7.3.280.0120.00316.35
7.3.260.0100.01116.42
7.3.240.0100.00716.35
7.3.230.0120.00616.38
7.3.210.0110.00416.32
7.3.200.0130.00616.36
7.3.190.0090.00916.25
7.3.180.0120.00916.40
7.3.170.0100.00716.64
7.3.160.0090.00616.36
7.2.330.0130.00416.70
7.2.320.0030.01516.51
7.2.310.0200.00316.35
7.2.300.0060.01216.79
7.2.290.0180.00416.50
7.2.110.1190.00914.66
7.2.100.1400.01314.62
7.2.90.1220.01514.62
7.2.80.1430.00314.37
7.2.70.1330.01014.84
7.2.60.0070.01414.91
7.2.50.1350.00714.94
7.2.40.1400.00314.89
7.2.30.1200.00615.01
7.2.20.1680.00314.93
7.2.10.1270.00015.09
7.2.00.1290.00314.80
7.1.230.1150.00613.61
7.1.220.1290.00313.61
7.1.210.1570.01013.60
7.1.200.1390.00313.79
7.1.190.1290.01013.73
7.1.180.1180.00313.93
7.1.170.1250.00013.95
7.1.160.1490.00313.74
7.1.150.1290.00313.85
7.1.140.1310.00013.89
7.1.130.1090.00914.05
7.1.120.1380.00313.74
7.1.110.1500.00614.00
7.1.100.1530.00614.07
7.1.90.1570.01313.86
7.1.80.1420.00714.05
7.1.70.1480.01013.81
7.1.60.2220.01031.90
7.1.50.1760.01031.99
7.1.40.1790.01031.86
7.1.30.1670.00331.93
7.1.20.1570.00631.84
7.1.10.0950.00013.86
7.1.00.1230.01013.56
5.6.380.0130.00314.46

preferences:
29.69 ms | 403 KiB | 5 Q