3v4l.org

run code in 300+ PHP versions simultaneously
<?php ## the user "class" class Foo { public int $id; public string $foo; public ?string $group = null; public function __construct(int $id, string $foo) { $this->id = $id; $this->foo = $foo; } } ## users db result $users_array = [ new Foo(999, 'abc'), new Foo(4, 'abc'), new Foo(5, 'xyz'), new Foo(8, 'xxx') ]; ## get IDs and build index $index = []; $ids = array_reduce($users_array, function(?array $ids, Foo $object) use(&$index) { $ids[] = $object->id; $index[$object->id] = $object; return $ids; }); ### Groups, fetched from SQL $groups = [ [ 'id' => 999, 'group' => 'group1'], [ 'id' => 8, 'group' => 'group2'], [ 'id' => 4, 'group' => 'group3'], ]; ### stiching foreach ($groups as $row) { $index[$row['id']]->group = $row['group']; } ## now the original array of users have their "group" property populated from the groups query var_dump($users_array);

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.0160.00016.75
8.3.60.0100.01018.43
8.3.50.0150.00318.15
8.3.40.0140.00720.45
8.3.30.0110.00418.43
8.3.20.0040.00420.95
8.3.10.0080.00020.25
8.3.00.0040.00422.31
8.2.190.0160.00016.88
8.2.180.0150.00618.29
8.2.170.0090.00922.96
8.2.160.0030.01019.33
8.2.150.0070.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00421.05
8.2.110.0050.00520.55
8.2.100.0060.00617.72
8.2.90.0000.00820.59
8.2.80.0040.00417.97
8.2.70.0080.00017.93
8.2.60.0040.00418.28
8.2.50.0080.00018.10
8.2.40.0060.00319.42
8.2.30.0040.00419.42
8.2.20.0000.00718.16
8.2.10.0070.00019.34
8.2.00.0040.00419.36
8.1.280.0110.00725.92
8.1.270.0080.00020.62
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0100.00023.82
8.1.230.0040.00821.04
8.1.220.0050.00317.74
8.1.210.0060.00319.02
8.1.200.0040.00417.35
8.1.190.0050.00317.25
8.1.180.0000.00818.97
8.1.170.0080.00018.46
8.1.160.0060.00318.96
8.1.150.0040.00418.85
8.1.140.0070.00018.91
8.1.130.0040.00421.92
8.1.120.0000.01117.58
8.1.110.0000.00717.44
8.1.100.0040.00417.53
8.1.90.0020.00517.51
8.1.80.0060.00317.50
8.1.70.0000.00717.40
8.1.60.0030.00617.61
8.1.50.0040.00417.59
8.1.40.0040.00417.57
8.1.30.0050.00317.66
8.1.20.0040.00417.71
8.1.10.0000.00717.65
8.1.00.0040.00417.43
8.0.300.0050.00320.03
8.0.290.0040.00416.88
8.0.280.0000.00818.40
8.0.270.0040.00416.84
8.0.260.0070.00020.04
8.0.250.0030.00516.94
8.0.240.0060.00317.05
8.0.230.0000.00817.12
8.0.220.0000.00816.96
8.0.210.0040.00416.86
8.0.200.0030.00317.06
8.0.190.0020.00516.97
8.0.180.0040.00416.92
8.0.170.0060.00317.04
8.0.160.0000.00917.07
8.0.150.0080.00016.86
8.0.140.0000.00716.84
8.0.130.0030.00313.42
8.0.120.0000.00816.96
8.0.110.0000.00816.93
8.0.100.0030.00516.84
8.0.90.0060.00317.06
8.0.80.0090.00816.98
8.0.70.0070.00016.90
8.0.60.0000.00816.88
8.0.50.0040.00417.05
8.0.30.0040.01516.94
8.0.20.0150.01017.02
8.0.10.0000.00717.07
8.0.00.0160.00916.82
7.4.330.0020.00215.55
7.4.320.0030.00516.47
7.4.300.0000.00716.55
7.4.290.0090.00016.37
7.4.280.0030.00516.55
7.4.270.0060.00316.63
7.4.260.0050.00013.30
7.4.250.0070.00016.60
7.4.240.0050.00316.54
7.4.230.0030.00316.48
7.4.220.0020.00516.51
7.4.210.0070.01016.64
7.4.200.0000.00716.57
7.4.130.0110.00816.52
7.4.120.0130.00916.56
7.4.110.0120.00916.46
7.4.100.0090.00816.67
7.4.90.0180.00316.70
7.4.80.0110.00719.39
7.4.70.0070.01016.62
7.4.60.0090.00916.59
7.4.50.0030.01316.42
7.4.40.0090.00916.45
7.4.30.0110.00416.72
7.4.20.0100.00716.29
7.4.10.0140.00316.42
7.4.00.0050.01216.64
7.3.330.0040.00416.16
7.3.320.0050.00012.95
7.3.310.0030.00316.04
7.3.300.0040.00416.13
7.3.290.0090.00416.18
7.3.280.0130.00716.11
7.3.260.0060.01116.52
7.3.240.0090.00816.31
7.3.230.0060.00916.23
7.3.210.0070.01016.17
7.3.200.0070.01316.28
7.3.190.0140.00416.36
7.3.180.0110.00416.36
7.3.170.0100.00716.27
7.3.160.0070.01016.29
7.3.150.0060.00916.21
7.3.140.0030.01216.17
7.3.130.0090.00616.33
7.3.120.0110.00316.32
7.3.110.0030.01216.34
7.3.100.0100.00515.98
7.3.90.0130.00616.20
7.3.80.0030.01616.01
7.3.70.0120.00416.21
7.3.60.0030.01216.21
7.3.50.0070.00716.12
7.3.40.0090.00616.02
7.3.30.0090.00616.05
7.3.20.0000.01516.28
7.3.10.0090.00616.05
7.3.00.0170.00316.11
7.2.330.0090.00916.58
7.2.320.0040.01316.15
7.2.310.0060.00916.53
7.2.300.0090.00616.53
7.2.290.0130.00316.38
7.2.280.0090.00616.37
7.2.270.0090.00616.40
7.2.260.0090.00616.33
7.2.250.0060.00916.38
7.2.240.0000.01515.86
7.2.230.0100.01116.54
7.2.220.0060.01316.24
7.2.210.0130.00916.18
7.2.200.0060.00916.27
7.2.190.0100.01016.24
7.2.180.0120.00316.31
7.2.170.0000.01516.06
7.2.160.0030.01216.36
7.2.150.0090.00616.29
7.2.140.0100.00716.38
7.2.130.0100.01316.24
7.2.120.0040.01216.23
7.2.110.0080.00816.45
7.2.100.0060.00916.35
7.2.90.0000.01616.50
7.2.80.0060.01016.43
7.2.70.0060.01016.50
7.2.60.0090.01216.60
7.2.50.0090.01216.20
7.2.40.0120.00616.44
7.2.30.0030.01516.14
7.2.20.0060.01616.08
7.2.10.0130.00916.27
7.2.00.0060.01616.22

preferences:
49.62 ms | 401 KiB | 5 Q