3v4l.org

run code in 300+ PHP versions simultaneously
<?php $canonicalIds = [ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', ]; $putContent = [ [ 'id' => 'fifth', 'value' => 55, ], [ 'id' => 'second', 'value' => 22, ], [ 'id' => 'fourth', 'value' => 44, ], [ 'id' => null, 'value' => 7, ], ]; function mySort(array $canonicalIds, array $putContent): array { $toCreate = $toUpdate = []; foreach ($putContent as $putItem) { if (null === $putItem['id']) { $toCreate[] = $putItem; } elseif (in_array($putItem['id'], $canonicalIds, true) === true) { $toUpdate[] = $putItem; } } $toDelete = array_diff($canonicalIds, array_column($toUpdate, 'id')); return [$toCreate, $toUpdate, $toDelete]; } [$toCreate, $toUpdate, $toDelete] = mySort($canonicalIds, $putContent); var_dump($toCreate, $toUpdate, $toDelete);

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.3.70.0080.01118.43
8.3.60.0100.01018.30
8.3.50.0110.01116.55
8.3.40.0110.00420.26
8.3.30.0000.01518.70
8.3.20.0000.00824.18
8.3.10.0030.00624.66
8.3.00.0040.00426.16
8.2.190.0150.00916.63
8.2.180.0150.00316.63
8.2.170.0100.01019.06
8.2.160.0100.00722.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0030.00521.18
8.2.110.0050.00521.04
8.2.100.0000.01217.71
8.2.90.0090.00017.75
8.2.80.0060.00317.97
8.2.70.0000.00817.93
8.2.60.0080.00017.93
8.2.50.0040.00418.07
8.2.40.0040.00418.35
8.2.30.0030.00618.03
8.2.20.0170.00318.86
8.2.10.0180.00318.95
8.2.00.0150.00419.07
8.1.280.0100.01025.92
8.1.270.0050.00323.92
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00319.20
8.1.230.0040.00820.88
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0050.00317.22
8.1.180.0030.00618.10
8.1.170.0050.00618.61
8.1.160.0030.00518.85
8.1.150.0030.00718.42
8.1.140.0130.00618.66
8.1.130.0100.00718.73
8.1.120.0120.00418.77
8.1.110.0110.00518.60
8.1.100.0090.00718.64
8.1.90.0110.00518.79
8.1.80.0130.00318.70
8.1.70.0150.00318.63
8.1.60.0090.01218.91
8.1.50.0200.00018.70
8.1.40.0110.00718.89
8.1.30.0160.00318.86
8.1.20.0060.00918.79
8.1.10.0110.00618.76
8.1.00.0100.00318.68
8.0.300.0080.00018.77
8.0.290.0000.00816.75
8.0.280.0030.00318.53
8.0.270.0140.00017.95
8.0.260.0040.01318.04
8.0.250.0120.00418.15
8.0.240.0080.00818.08
8.0.230.0100.00518.12
8.0.220.0150.00017.96
8.0.210.0060.00817.88
8.0.200.0060.00618.14
8.0.190.0060.00618.09
8.0.180.0080.00818.00
8.0.170.0120.00418.02
8.0.160.0080.00817.97
8.0.150.0060.00618.04
8.0.140.0050.00917.98
8.0.130.0050.00917.91
8.0.120.0110.00417.99
8.0.110.0100.00517.99
8.0.100.0140.00018.00
8.0.90.0130.00318.02
8.0.80.0120.00418.10
8.0.70.0100.00818.03
8.0.60.0120.00417.94
8.0.50.0090.00617.97
8.0.30.0110.00417.93
8.0.20.0080.00818.05
8.0.10.0150.00018.12

preferences:
32.73 ms | 402 KiB | 5 Q