3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ (object) ['id'=> 1, 'value' => 0], (object) ['id'=> 2, 'value' => 10], (object) ['id'=> 3, 'value' => 14], (object) ['id'=> 4, 'value' => 0], (object) ['id'=> 5, 'value' => 21], (object) ['id'=> 6, 'value' => 44], ]; $result = []; foreach ($array as $obj) { if (!$obj->value) { unset($ref); $obj->values = []; $ref = &$obj->values; $result[] = $obj; continue; } $ref[] = $obj; } var_export($result);

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.140.0200.00817.57
8.4.130.0060.01117.89
8.4.120.0130.00620.47
8.4.110.0130.00720.48
8.4.100.0110.01020.28
8.4.90.0060.00418.95
8.4.80.0140.00718.91
8.4.70.0100.00618.18
8.4.60.0100.00719.14
8.4.50.0090.00618.49
8.4.40.0130.00620.70
8.4.30.0040.00418.64
8.4.20.0130.00717.85
8.4.10.0190.00024.11
8.3.270.0150.00716.77
8.3.260.0130.00616.66
8.3.250.0130.00519.00
8.3.240.0140.00616.59
8.3.230.0130.00616.84
8.3.220.0100.00619.07
8.3.210.0030.00418.31
8.3.200.0060.00216.74
8.3.190.0100.00516.95
8.3.180.0100.00816.86
8.3.170.0060.01218.74
8.3.160.0090.00917.10
8.3.150.0120.00616.99
8.3.140.0110.00416.80
8.3.130.0080.00016.75
8.3.120.0030.00620.81
8.3.110.0040.00720.94
8.3.100.0060.00318.68
8.3.90.0060.00326.77
8.3.80.0040.00416.63
8.3.70.0050.01018.18
8.3.60.0170.00318.52
8.3.50.0080.00818.51
8.3.40.0110.00720.30
8.3.30.0030.01018.93
8.3.20.0120.00324.18
8.3.10.0050.00324.66
8.3.00.0000.00926.16
8.2.290.0130.00520.51
8.2.280.0100.00818.40
8.2.270.0030.01719.22
8.2.260.0040.00418.25
8.2.250.0040.00416.82
8.2.240.0130.00717.01
8.2.230.0060.00322.58
8.2.220.0000.00824.06
8.2.210.0000.00826.77
8.2.200.0040.00418.18
8.2.190.0110.01116.58
8.2.180.0090.01225.92
8.2.170.0030.01018.91
8.2.160.0040.01122.96
8.2.150.0040.01125.66
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0040.00426.16
8.2.110.0030.00720.43
8.2.100.0060.00617.97
8.2.90.0000.00917.88
8.2.80.0050.00318.91
8.2.70.0040.00417.63
8.2.60.0000.00818.04
8.2.50.0000.00918.07
8.2.40.0030.00618.03
8.2.30.0000.00818.16
8.2.20.0070.00019.31
8.2.10.0070.00018.04
8.2.00.0080.00019.31
8.1.330.0110.00821.88
8.1.320.0090.01016.25
8.1.310.0090.00916.43
8.1.300.0100.00618.02
8.1.290.0070.00430.84
8.1.280.0150.00625.92
8.1.270.0080.00024.66
8.1.260.0070.00026.35
8.1.250.0150.00028.09
8.1.240.0060.00320.84
8.1.230.0090.00317.85
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00617.22
8.1.190.0060.00317.23
8.1.180.0060.00318.10
8.1.170.0000.00818.65
8.1.160.0040.00418.89
8.1.150.0040.00418.52
8.1.140.0000.00817.49
8.1.130.0000.00718.89
8.1.120.0000.00717.36
8.1.110.0000.00817.46
8.1.100.0000.00717.36
8.1.90.0000.00917.31
8.1.80.0170.00017.30
8.1.70.0090.00917.26
8.1.60.0150.00617.38
8.1.50.0170.00417.39
8.1.40.0130.00417.46
8.1.30.0060.00617.66
8.1.20.0090.00417.61
8.1.10.0050.00917.25
8.1.00.0110.00417.39
8.0.300.0000.00818.77
8.0.290.0000.00816.75
8.0.280.0070.00018.49
8.0.270.0040.00416.96
8.0.260.0030.00318.45
8.0.250.0030.00316.93
8.0.240.0000.00617.04
8.0.230.0070.00017.01
8.0.220.0090.00216.89
8.0.210.0040.00716.90
8.0.200.0110.00416.89
8.0.190.0110.00516.89
8.0.180.0080.00816.94
8.0.170.0140.00016.92
8.0.160.0110.00216.84
8.0.150.0130.00016.69
8.0.140.0090.00416.79
8.0.130.0070.00716.71
8.0.120.0150.00016.79
8.0.110.0140.00016.93
8.0.100.0120.00316.80
8.0.90.0100.00516.78
8.0.80.0100.00516.87
8.0.70.0160.00016.82
8.0.60.0080.00816.91
8.0.50.0070.00716.76
8.0.30.0000.01416.87
8.0.20.0160.00016.82
8.0.10.0120.00316.90
7.4.330.0000.00615.55
7.4.320.0000.00616.58
7.4.300.0040.00416.60
7.4.290.0100.00316.55
7.4.280.0090.01116.56
7.4.270.0120.00416.60
7.4.260.0050.01416.58
7.4.250.0080.00816.42
7.4.240.0100.00716.45
7.4.230.0140.00316.52
7.4.220.0150.00016.52
7.4.210.0100.00316.57
7.4.200.0110.00416.37
7.4.190.0070.00716.55
7.4.180.0090.00616.52
7.4.160.0070.00716.29
7.4.150.0120.00316.45
7.4.140.0100.00316.25
7.4.130.0070.00716.24
7.4.120.0070.00716.31
7.4.110.0100.00516.39
7.4.100.0070.00616.51
7.4.90.0040.00416.36
7.4.80.0000.00816.30
7.4.70.0030.00616.24
7.4.60.0040.00416.31
7.4.50.0050.00516.21
7.4.40.0030.00716.33
7.4.30.0050.00516.30
7.4.20.0100.00016.22
7.4.10.0030.00616.40
7.4.00.0070.00216.46

preferences:
118.79 ms | 403 KiB | 5 Q