3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(array('table' => 'test', 'parent_table' => NULL), array('table' => 'test', 'parent_table' => NULL), array('table' => 'test2', 'parent_table' => 'test'), array('table' => 'test4', 'parent_table' => NULL), array('table' => 'test5', 'parent_table' => 'test3'), array('table' => 'test6', 'parent_table' => 'test5'), array('table' => 'test3', 'parent_table' => 'test')); function hsort($array, $parent) { $output = array(); $children = array_filter($array, function ($v) use ($parent) { return $v['parent_table'] === $parent; }); sort($children); $lastchild = NULL; foreach ($children as $child) { if ($child != $lastchild && !is_null($lastchild)) { $output[] = $lastchild; $output = array_merge($output, hsort($array, $lastchild['table'])); } elseif ($lastchild != NULL) { $output[] = $lastchild; } $lastchild = $child; } if (!is_null($lastchild)) { $output[] = $lastchild; $output = array_merge($output, hsort($array, $lastchild['table'])); } return $output; } echo "table | parent_table\n"; foreach (hsort($array, NULL) as $v) { printf("%-8s| %s\n", $v['table'], $v['parent_table'] ?? 'NULL'); }

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.0160.00517.84
8.4.110.0140.00720.40
8.4.100.0040.00517.66
8.4.90.0110.00620.39
8.4.80.0100.00719.05
8.4.70.0130.00618.04
8.4.60.0090.00718.57
8.4.50.0090.01218.82
8.4.40.0100.01019.61
8.4.30.0060.01317.93
8.4.20.0160.00320.30
8.4.10.0060.00317.78
8.3.250.0110.00816.53
8.3.240.0040.00516.70
8.3.230.0150.00516.61
8.3.220.0060.01219.21
8.3.210.0050.00316.76
8.3.200.0050.00416.63
8.3.190.0100.00516.72
8.3.180.0050.00416.97
8.3.170.0120.00618.70
8.3.160.0090.00920.34
8.3.150.0100.01017.27
8.3.140.0090.00917.11
8.3.130.0030.00618.46
8.3.120.0160.00320.63
8.3.110.0130.00620.94
8.3.100.0000.00824.06
8.3.90.0130.00326.77
8.3.80.0050.00519.36
8.3.70.0040.01118.56
8.3.60.0070.01118.56
8.3.50.0100.01018.31
8.3.40.0120.00318.79
8.3.30.0030.01018.77
8.3.20.0000.00821.08
8.3.10.0000.00821.72
8.3.00.0060.00321.91
8.2.290.0070.00416.99
8.2.280.0120.00818.60
8.2.270.0120.00618.78
8.2.260.0120.00316.42
8.2.250.0080.00018.63
8.2.240.0040.00418.86
8.2.230.0080.00022.58
8.2.220.0030.00637.54
8.2.210.0080.00026.77
8.2.200.0040.01118.88
8.2.190.0040.01118.54
8.2.180.0060.01216.63
8.2.170.0110.00422.96
8.2.160.0120.00419.45
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0070.00726.16
8.2.120.0040.00421.15
8.2.110.0100.00321.07
8.2.100.0090.00317.84
8.2.90.0080.00019.34
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0030.00517.93
8.2.50.0000.00818.07
8.2.40.0040.00419.95
8.2.30.0000.00718.02
8.2.20.0050.00318.06
8.2.10.0000.00719.26
8.2.00.0040.00418.11
8.1.330.0150.00516.24
8.1.320.0130.00816.41
8.1.310.0060.01218.34
8.1.300.0030.00620.17
8.1.290.0110.00430.84
8.1.280.0140.00725.92
8.1.270.0070.00018.91
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0090.00022.14
8.1.230.0070.00422.68
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0060.00317.48
8.1.190.0080.00017.23
8.1.180.0080.00018.10
8.1.170.0080.00318.69
8.1.160.0040.00418.97
8.1.150.0000.00718.97
8.1.140.0030.00518.87
8.1.130.0060.00320.20
8.1.120.0040.00317.51
8.1.110.0040.00417.51
8.1.100.0080.00017.48
8.1.90.0040.00417.49
8.1.80.0060.00317.50
8.1.70.0000.00717.49
8.1.60.0030.00617.60
8.1.50.0080.00017.54
8.1.40.0000.00817.57
8.1.30.0040.00417.50
8.1.20.0040.00417.71
8.1.10.0000.00817.59
8.1.00.0060.00317.41
8.0.300.0030.00619.63
8.0.290.0040.00416.75
8.0.280.0040.00418.36
8.0.270.0000.00717.32
8.0.260.0000.00618.45
8.0.250.0030.00316.99
8.0.240.0030.00317.00
8.0.230.0040.00417.05
8.0.220.0070.00016.95
8.0.210.0070.00016.96
8.0.200.0070.00316.93
8.0.190.0000.00716.93
8.0.180.0080.00016.83
8.0.170.0030.00616.94
8.0.160.0000.00716.94
8.0.150.0020.00516.93
8.0.140.0000.00816.76
8.0.130.0030.00313.36
8.0.120.0070.00016.87
8.0.110.0050.00216.93
8.0.100.0070.00016.84
8.0.90.0020.00516.94
8.0.80.0060.00916.93
8.0.70.0000.00716.93
8.0.60.0050.00216.68
8.0.50.0050.00316.70
8.0.30.0100.00917.19
8.0.20.0120.01217.48
8.0.10.0000.00817.03
8.0.00.0150.00416.73
7.4.330.0030.00315.55
7.4.320.0000.00616.51
7.4.300.0060.00016.52
7.4.290.0030.00316.51
7.4.280.0000.00716.55
7.4.270.0060.00316.52
7.4.260.0030.00516.49
7.4.250.0000.00716.48
7.4.240.0000.00816.43
7.4.230.0040.00416.56
7.4.220.0040.00416.50
7.4.210.0070.01016.58
7.4.200.0040.00416.41
7.4.160.0110.00416.47
7.4.140.0110.00717.86
7.4.130.0120.00616.53
7.4.120.0070.01516.57
7.4.110.0090.00916.61
7.4.100.0120.00416.53
7.4.90.0030.01316.38
7.4.80.0040.01919.39
7.4.70.0130.00716.79
7.4.60.0090.01216.51
7.4.50.0080.00616.56
7.4.40.0060.01016.54
7.4.00.0070.00914.90
7.3.330.0000.00513.14
7.3.320.0030.00313.29
7.3.310.0040.00416.22
7.3.300.0000.00716.41
7.3.290.0000.00716.18
7.3.280.0050.01116.30
7.3.260.0120.01316.53
7.3.240.0080.01116.44
7.3.230.0170.00616.42
7.3.210.0120.00916.38
7.3.200.0120.00916.40
7.3.190.0130.00416.64
7.3.180.0040.01316.44
7.3.170.0110.01116.31
7.3.160.0080.00816.30
7.3.120.0170.00014.84
7.3.110.0070.01015.02
7.3.100.0100.00314.94
7.3.90.0120.00614.50
7.3.80.0090.00614.87
7.3.70.0120.00614.75
7.3.60.0030.01014.70
7.3.50.0070.00614.73
7.3.40.0040.00714.96
7.3.30.0000.01614.56
7.3.20.0080.00616.71
7.3.10.0380.00915.82
7.3.00.0360.00715.72
7.2.330.0140.00316.80
7.2.320.0100.00616.85
7.2.310.0090.00816.80
7.2.300.0070.01016.86
7.2.290.0060.01016.59
7.2.250.0060.01315.03
7.2.240.0090.00915.11
7.2.230.0060.00914.90
7.2.220.0040.01115.25
7.2.210.0060.00915.09
7.2.200.0030.01315.04
7.2.190.0070.00314.90
7.2.180.0040.01115.13
7.2.170.0110.00715.21
7.2.130.0690.00014.92
7.2.120.0800.00615.15
7.2.110.0720.00314.86
7.2.100.0690.01014.96
7.2.90.0910.00615.18
7.2.80.0680.01314.85
7.2.70.0650.00015.03
7.2.60.0670.00715.05
7.2.50.0870.00014.89
7.2.40.0740.00315.12
7.2.30.0770.00015.14
7.2.20.0590.01015.20
7.2.10.0970.01014.98
7.2.00.0860.00714.99
7.1.330.0060.00815.78
7.1.320.0070.00715.82
7.1.310.0000.01315.85
7.1.300.0100.00715.66
7.1.290.0070.01015.69
7.1.280.0000.01415.67
7.1.270.0030.00915.67
7.1.260.0040.01115.66
7.1.250.1080.01314.00

preferences:
129.84 ms | 403 KiB | 5 Q