3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'dir1' => [ 'dir2' => [ 'dir3' => [ 'dir4' => [ 'file1.php', 'abc.php', ] ], 'file2.php', 'abc.php', ] ], 'bar' => [ 'foo12' => ['blah', 'blar', 'blag', 'blas'], 'foo9' => ['boom6', 'boom55', 'boom123'], 'foo888' => [], ], 'abc' => [ 'abc' => [ 'abc' => [ 'file5.php', ] ] ] ]; function sortFileSystem(array &$array) { $dirs = []; $files = []; foreach ($array as $k => &$v) { if (is_array($v)) { (__FUNCTION__)($v); $dirs[$k] = $v; // preserve key } else { $files[] = $v; // key is unneeded } } ksort($dirs, SORT_NATURAL); sort($files, SORT_NATURAL); $array = array_merge($dirs, $files); // put dirs before files } sortFileSystem($array); var_export($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.4.140.0050.00417.54
8.4.130.0120.00717.77
8.4.120.0120.00520.45
8.4.110.0120.00722.32
8.4.100.0120.00817.33
8.4.90.0100.00817.49
8.4.80.0120.00917.59
8.4.70.0130.00717.67
8.4.60.0100.01018.74
8.4.50.0080.00717.61
8.4.40.0080.00817.79
8.4.30.0130.00718.84
8.4.20.0100.01017.80
8.4.10.0080.00019.65
8.3.270.0120.00716.56
8.3.260.0110.00916.94
8.3.250.0120.00619.13
8.3.240.0110.00816.87
8.3.230.0030.00516.42
8.3.220.0080.01117.39
8.3.210.0120.00616.56
8.3.200.0060.00316.46
8.3.190.0100.00817.18
8.3.180.0120.00718.97
8.3.170.0130.00620.39
8.3.160.0000.01819.22
8.3.150.0130.00617.13
8.3.140.0050.00317.14
8.3.130.0080.00018.52
8.3.120.0080.00318.74
8.3.110.0060.00320.94
8.3.100.0000.00918.61
8.3.90.0140.00426.77
8.3.80.0090.00017.97
8.3.70.0150.00616.63
8.3.60.0090.00618.60
8.3.50.0210.00016.79
8.3.40.0100.01021.68
8.3.30.0100.00322.15
8.3.20.0100.01025.66
8.3.10.0130.00725.66
8.3.00.0160.00025.66
8.2.290.0120.00820.50
8.2.280.0110.00918.50
8.2.270.0040.00717.03
8.2.260.0020.00518.15
8.2.250.0110.00718.82
8.2.240.0060.00319.11
8.2.230.0090.00022.58
8.2.220.0080.00024.06
8.2.210.0090.00926.77
8.2.200.0030.00618.41
8.2.190.0040.01116.58
8.2.180.0100.01016.75
8.2.170.0040.01118.96
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00425.66
8.2.130.0000.00825.66
8.2.120.0050.00325.66
8.2.110.0000.00825.66
8.2.100.0060.00325.66
8.2.90.0090.00925.66
8.2.80.0030.00625.66
8.2.70.0070.01125.66
8.2.60.0040.00425.66
8.2.50.0130.00625.66
8.2.40.0070.01125.66
8.2.30.0030.00625.66
8.2.20.0050.00325.66
8.2.10.0030.00625.66
8.2.00.0040.01125.66
8.1.330.0090.00918.49
8.1.320.0110.01016.16
8.1.310.0000.00816.88
8.1.300.0120.00619.44
8.1.290.0060.00330.84
8.1.280.0140.00725.92
8.1.270.0000.00925.66
8.1.260.0060.00925.66
8.1.250.0040.00425.66
8.1.240.0040.00425.66
8.1.230.0110.00425.66
8.1.220.0040.00425.66
8.1.210.0000.00825.66
8.1.200.0000.00825.66
8.1.190.0000.00825.66
8.1.180.0030.00625.66
8.1.170.0120.00625.66
8.1.160.0030.00625.66
8.1.150.0040.01225.66
8.1.140.0090.00625.66
8.1.130.0040.00425.66
8.1.120.0080.00025.66
8.1.110.0040.00425.66
8.1.100.0060.00325.66
8.1.90.0030.01425.66
8.1.80.0100.00025.66
8.1.70.0060.00325.66
8.1.60.0060.00325.66
8.1.50.0040.00425.66
8.1.40.0040.00425.66
8.1.30.0080.00025.66
8.1.20.0080.00025.66
8.1.10.0090.00025.66
8.1.00.0060.00325.66

preferences:
29.63 ms | 403 KiB | 5 Q