3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dirs = ['/chris', '/chris/usa', '/david', '/', '/chris/canada/2022', '/david/uk']; $current_path = "/"; $sub_dirs = []; foreach($dirs as $dir) { // Ensure $dir starts with path + '/' (sub dir of $current_path) if (strpos($dir, $current_path) === false) { continue; } // Get the relative path from $current_path $relPath = substr($dir, strlen($current_path)); // Get the first dir of this path [$dir2] = explode('/', ltrim($relPath,'/')); if (empty($dir2)) { continue; } // Store and add removed slash $sub_dirs[] = '/' . $dir2; } var_export(array_unique($sub_dirs));

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.5.10.0090.00920.26
8.5.00.0140.00820.07
8.4.160.0100.01120.45
8.4.150.0030.00014.05
8.4.140.0070.01417.49
8.4.130.0120.00817.73
8.4.120.0060.00320.63
8.4.110.0100.01118.87
8.4.100.0120.00817.63
8.4.90.0110.00918.84
8.4.80.0090.00817.71
8.4.70.0130.00717.77
8.4.60.0100.01118.60
8.4.50.0120.00917.75
8.4.40.0040.00419.41
8.4.30.0080.01120.85
8.4.20.0060.00319.89
8.4.10.0160.00323.97
8.3.280.0100.01218.36
8.3.270.0090.01216.73
8.3.260.0140.00616.84
8.3.250.0110.00719.12
8.3.240.0090.00716.78
8.3.230.0130.00516.55
8.3.220.0040.00417.20
8.3.210.0100.00816.64
8.3.200.0050.00416.63
8.3.190.0100.01017.41
8.3.180.0090.01016.61
8.3.170.0120.00618.80
8.3.160.0090.00918.50
8.3.150.0000.00820.81
8.3.140.0040.00416.81
8.3.130.0030.00618.61
8.3.120.0120.00821.03
8.3.110.0070.00416.62
8.3.100.0160.00316.76
8.3.90.0110.00426.77
8.3.80.0070.00318.28
8.3.70.0180.00018.56
8.3.60.0040.01116.50
8.3.50.0150.00018.39
8.3.40.0150.00320.34
8.3.30.0150.00018.85
8.3.20.0040.00424.18
8.3.10.0060.00324.66
8.3.00.0000.00726.16
8.2.290.0100.00920.70
8.2.280.0050.01019.80
8.2.270.0120.00618.96
8.2.260.0050.00318.97
8.2.250.0120.00616.56
8.2.240.0040.00417.39
8.2.230.0060.00320.94
8.2.220.0050.00524.06
8.2.210.0080.00026.77
8.2.200.0050.00517.00
8.2.190.0140.00716.58
8.2.180.0150.00025.92
8.2.170.0040.01118.93
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00318.01
8.2.110.0040.00420.53
8.2.100.0070.00322.25
8.1.330.0110.00917.84
8.1.320.0130.00816.36
8.1.310.0110.00616.94
8.1.300.0000.01616.14
8.1.290.0110.00030.84
8.1.280.0080.00625.92
8.1.270.0030.00524.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00418.88
8.1.230.0090.00018.61
7.4.330.0030.00316.79

preferences:
32.73 ms | 403 KiB | 5 Q