3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( array("id" => "Cosmetics", "parent" => "Beauty"), array("id" => "Makeup", "parent" => "Cosmetics"), array("id" => "Beauty", "parent" => null) ); $options = array(); $refs = array(); foreach($input as &$category) { $refs[$category["id"]] = $option = array( "id" => $category["id"], "options" => array() ); print_r($refs); if($category["parent"]){ if(!array_key_exists($category["parent"], $refs)) { $parent = array( "id" => $category["parent"], "options" => array( &$refs[$category["id"]] ) ); $refs[$parent["id"]] = &$refs[$parent["id"]]; } else { $refs[$category["parent"]]["options"][] = &$option; // print_r($refs[$category["parent"]]); } } else { $options[] = $refs[$category["id"]]; } } print_r($options);

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.60.0150.00016.50
8.3.50.0110.00316.49
8.3.40.0140.00718.77
8.3.30.0070.00718.84
8.3.20.0000.00818.73
8.3.10.0090.00020.02
8.3.00.0040.00418.16
8.2.180.0130.00718.27
8.2.170.0120.00322.96
8.2.160.0070.00719.32
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0070.00021.02
8.2.120.0080.00026.35
8.2.110.0060.00320.97
8.2.100.0110.00018.05
8.2.90.0040.00419.26
8.2.80.0030.00617.97
8.2.70.0040.00417.75
8.2.60.0050.00318.05
8.2.50.0000.00818.10
8.2.40.0090.00022.32
8.2.30.0040.00420.57
8.2.20.0050.00217.75
8.2.10.0050.00218.19
8.2.00.0030.00718.18
8.1.280.0070.01425.92
8.1.270.0080.00023.97
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00322.14
8.1.230.0120.00019.29
8.1.220.0050.00317.74
8.1.210.0060.00318.77
8.1.200.0080.00417.13
8.1.190.0040.00417.13
8.1.180.0080.00018.10
8.1.170.0050.00518.94
8.1.160.0030.00319.02
8.1.150.0030.00518.96
8.1.140.0050.00319.54
8.1.130.0040.00417.66
8.1.120.0030.00317.38
8.1.110.0050.00317.43
8.1.100.0000.00917.38
8.1.90.0070.00017.35
8.1.80.0030.00317.42
8.1.70.0040.00417.36
8.1.60.0000.00817.62
8.1.50.0030.00517.55
8.1.40.0080.00017.50
8.1.30.0040.00417.61
8.1.20.0030.00517.61
8.1.10.0020.00517.36
8.1.00.0070.00017.47
8.0.300.0030.00618.77
8.0.290.0070.00016.75
8.0.280.0000.00818.36
8.0.270.0000.00717.27
8.0.260.0090.00017.23
8.0.250.0030.00317.00
8.0.240.0080.00016.94
8.0.230.0040.00416.93
8.0.220.0000.00816.87
8.0.210.0000.00716.94
8.0.200.0030.00316.97
8.0.190.0030.00717.00
8.0.180.0040.00416.82
8.0.170.0090.00016.93
8.0.160.0030.00616.98
8.0.150.0030.00316.90
8.0.140.0070.00016.88
8.0.130.0000.00513.32
8.0.120.0040.00416.96
8.0.110.0000.00716.80
8.0.100.0000.00716.81
8.0.90.0070.00016.94
8.0.80.0070.01616.93
8.0.70.0040.00416.78
8.0.60.0000.00716.83
8.0.50.0040.00417.01
8.0.30.0070.01117.16
8.0.20.0140.01017.40
8.0.10.0040.00417.00
8.0.00.0080.01016.75
7.4.330.0000.00515.11
7.4.320.0030.00316.61
7.4.300.0070.00016.50
7.4.290.0040.00416.61
7.4.280.0050.00316.40
7.4.270.0030.00316.54
7.4.260.0030.00316.58
7.4.250.0050.00516.59
7.4.240.0070.00016.52
7.4.230.0080.00016.63
7.4.220.0250.01116.67
7.4.210.0060.01016.62
7.4.200.0000.00716.61
7.4.160.0120.00416.55
7.4.150.0100.00717.40
7.4.140.0030.01417.86
7.4.130.0080.01016.51
7.4.120.0120.00716.47
7.4.110.0080.01216.72
7.4.100.0080.00816.53
7.4.90.0160.00816.56
7.4.80.0060.01019.39
7.4.70.0110.00616.50
7.4.60.0100.00616.44
7.4.50.0030.01216.43
7.4.40.0130.00616.61
7.4.30.0040.01216.26
7.4.00.0120.00415.15
7.3.330.0060.00013.23
7.3.320.0020.00213.19
7.3.310.0030.00316.45
7.3.300.0020.00516.23
7.3.290.0030.00316.18
7.3.280.0070.01016.36
7.3.270.0210.00017.40
7.3.260.0110.00816.58
7.3.250.0160.00716.45
7.3.240.0110.00616.50
7.3.230.0120.00816.49
7.3.210.0080.00816.38
7.3.200.0090.01219.39
7.3.190.0130.00316.44
7.3.180.0120.00816.41
7.3.170.0070.01016.48
7.3.160.0090.00616.30
7.2.330.0170.00316.82
7.2.320.0090.00916.88
7.2.310.0080.00816.83
7.2.300.0170.00716.76
7.2.290.0100.00616.82
7.2.110.0060.01016.52
7.2.60.0000.01317.02
7.2.00.0060.00619.54
7.1.200.0040.00815.84
7.1.100.0060.00618.37
7.1.70.0040.00816.70
7.1.60.0070.01719.30
7.1.00.0000.08022.40
7.0.200.0290.00014.98
7.0.60.0230.07719.97
7.0.50.0270.04720.38
7.0.40.0400.05720.39
7.0.30.0170.07020.41
7.0.20.0230.06720.20
7.0.10.0330.05720.39
7.0.00.0470.06020.40
5.6.280.0070.05020.89
5.6.210.0100.04020.71
5.6.200.0130.06721.06
5.6.190.0270.06021.13
5.6.180.0300.06021.02
5.6.170.0300.05321.15
5.6.160.0370.05321.09
5.6.150.0430.08021.02
5.6.140.0070.08021.04
5.6.130.0400.05020.94
5.6.120.0100.06021.12
5.6.110.0100.09321.08
5.6.100.0230.05721.11
5.6.90.0070.06721.02
5.6.80.0300.05720.54
5.6.70.0330.06020.46
5.6.60.0330.05020.45
5.6.50.0270.06020.52
5.6.40.0170.05320.48
5.6.30.0100.06320.43
5.6.20.0300.05320.50
5.6.10.0330.05320.45
5.6.00.0100.06320.39
5.5.350.0370.07020.42
5.5.340.0270.05320.86
5.5.330.0300.05720.84
5.5.320.0270.05720.84
5.5.310.0300.05720.91
5.5.300.0300.06321.01
5.5.290.0400.05720.88
5.5.280.0230.07720.88
5.5.270.0170.06321.00
5.5.260.0170.07721.02
5.5.250.0100.06320.69
5.5.240.0330.06020.22
5.5.230.0370.06020.25
5.5.220.0270.06020.22
5.5.210.0270.05720.27
5.5.200.0070.06020.39
5.5.190.0370.04720.34
5.5.180.0200.06020.20
5.5.160.0070.06020.25
5.5.150.0100.05720.14
5.5.140.0230.06320.18
5.5.130.0470.06320.23
5.5.120.0270.06320.36
5.5.110.0400.06020.03
5.5.100.0270.05320.16
5.5.90.0330.05020.29
5.5.80.0300.05020.15
5.5.70.0230.06020.06
5.5.60.0370.04720.01
5.5.50.0300.05020.17
5.5.40.0300.06320.01
5.5.30.0330.07320.23
5.5.20.0370.05320.10
5.5.10.0300.06020.20
5.5.00.0400.05020.13

preferences:
63.97 ms | 401 KiB | 5 Q