3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'https://example.com/folder1/folder2/style.css'; $paths = [ 'img/example1.png', '/img/example2.png', '../img/example3.png', '../../img/example4.png', 'https://example.com/folder1/folder2/example5.png' ]; $folders = explode('/', trim(parse_url($url, PHP_URL_PATH), '/')); array_pop($folders); $prefix = explode('/' . $folders[0] . '/', $url)[0]; // need to be improved using parse_url to re-build // properly the url with the correct syntax for each scheme. function getURLFromPath($path, $prefix, $folders) { if ( parse_url($path, PHP_URL_SCHEME) ) return $path; foreach (explode('/', ltrim($path, '/')) as $item) { if ( $item === '..' ) { array_pop($folders); } elseif ( $item === '.' ) { } else { $folders[] = $item; } } return $prefix . '/' . implode('/', $folders); } foreach ($paths as $path) { echo getURLFromPath($path, $prefix, $folders), PHP_EOL; }

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.0120.00822.27
8.4.110.0120.00822.46
8.4.100.0100.01117.99
8.4.90.0120.00917.47
8.4.80.0060.00317.81
8.4.70.0050.00617.89
8.4.60.0140.00718.70
8.4.50.0080.01019.44
8.4.40.0120.00417.73
8.4.30.0120.00319.41
8.4.20.0100.01019.19
8.4.10.0070.00417.78
8.3.250.0100.00918.87
8.3.240.0100.00916.85
8.3.230.0120.00716.62
8.3.220.0110.00517.29
8.3.210.0090.00916.81
8.3.200.0100.00916.70
8.3.190.0100.01016.61
8.3.180.0050.00316.53
8.3.170.0110.00717.20
8.3.160.0120.00616.47
8.3.150.0160.00318.25
8.3.140.0120.00617.34
8.3.130.0040.00418.36
8.3.120.0110.00018.86
8.3.110.0070.00420.94
8.3.100.0090.00624.06
8.3.90.0040.01426.77
8.3.80.0090.00017.97
8.3.70.0110.01116.50
8.3.60.0150.00018.20
8.3.50.0250.00517.90
8.3.40.0040.01118.82
8.3.30.0140.00018.79
8.3.20.0070.00021.73
8.3.10.0070.00021.93
8.3.00.0040.00423.65
8.2.290.0100.00820.79
8.2.280.0110.01118.38
8.2.270.0070.00417.14
8.2.260.0040.00416.48
8.2.250.0050.00317.01
8.2.240.0040.00419.18
8.2.230.0080.00022.58
8.2.220.0040.00437.54
8.2.210.0040.01126.77
8.2.200.0030.00618.28
8.2.190.0160.00618.53
8.2.180.0110.00416.75
8.2.170.0000.01422.96
8.2.160.0110.00419.84
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0000.00721.04
8.2.120.0050.00326.35
8.2.110.0070.00321.05
8.2.100.0120.00017.84
8.2.90.0000.00817.91
8.2.80.0030.00518.05
8.2.70.0040.00417.80
8.2.60.0090.00018.28
8.2.50.0000.00818.10
8.2.40.0000.00719.27
8.2.30.0040.00420.97
8.2.20.0040.00418.08
8.2.10.0050.00318.12
8.2.00.0050.00319.32
8.1.330.0130.00518.39
8.1.320.0130.00816.41
8.1.310.0080.00018.69
8.1.300.0040.00417.84
8.1.290.0030.00730.84
8.1.280.0110.00725.92
8.1.270.0080.00023.90
8.1.260.0080.00026.35
8.1.250.0050.00228.09
8.1.240.0030.00722.27
8.1.230.0040.00822.73
8.1.220.0080.00017.79
8.1.210.0060.00318.77
8.1.200.0000.01017.35
8.1.190.0000.00817.35
8.1.180.0050.00318.10
8.1.170.0040.00418.37
8.1.160.0000.00718.79
8.1.150.0080.00018.93
8.1.140.0000.00717.65
8.1.130.0000.00718.89
8.1.120.0000.00817.46
8.1.110.0070.00017.45
8.1.100.0000.00917.48
8.1.90.0000.00717.45
8.1.80.0040.00417.35
8.1.70.0070.00017.38
8.1.60.0000.00817.59
8.1.50.0030.00617.46
8.1.40.0060.00317.50
8.1.30.0000.00817.57
8.1.20.0000.00717.48
8.1.10.0040.00417.63
8.1.00.0050.00317.50
8.0.300.0040.00421.95
8.0.290.0030.00616.63
8.0.280.0000.00818.46
8.0.270.0070.00017.28
8.0.260.0050.00217.28
8.0.250.0000.00817.00
8.0.240.0070.00016.93
8.0.230.0030.00716.88
8.0.220.0000.00816.82
8.0.210.0040.00416.80
8.0.200.0070.00016.89
8.0.190.0020.00516.88
8.0.180.0040.00416.90
8.0.170.0040.00416.82
8.0.160.0040.00416.88
8.0.150.0040.00416.82
8.0.140.0030.00316.84
8.0.130.0030.00313.29
8.0.120.0000.00816.88
8.0.110.0030.00616.83
8.0.100.0050.00216.97
8.0.90.0030.00316.73
8.0.80.0060.00916.79
8.0.70.0040.00417.00
8.0.60.0080.00016.79
8.0.50.0040.00417.02
8.0.30.0060.01217.12
8.0.20.0110.00817.40
8.0.10.0040.00416.85
8.0.00.0110.00816.72
7.4.330.0060.00015.55
7.4.320.0030.00316.51
7.4.300.0040.00416.57
7.4.290.0030.00316.46
7.4.280.0040.00416.46
7.4.270.0040.00416.63
7.4.260.0030.00516.45
7.4.250.0030.00516.41
7.4.240.0030.00316.63
7.4.230.0000.00716.68
7.4.220.0040.00416.26
7.4.210.0050.01016.62
7.4.200.0070.00016.40
7.4.160.0100.00816.62
7.4.140.0150.01117.86
7.4.130.0120.00716.63
7.4.120.0080.01016.62
7.4.110.0030.01316.66
7.4.100.0070.01016.45
7.4.90.0170.00016.54
7.4.80.0120.00619.39
7.4.70.0140.00316.63
7.4.60.0090.00916.54
7.4.50.0070.00716.35
7.4.40.0100.00616.55
7.4.00.0090.00614.90
7.3.330.0000.00513.48
7.3.320.0030.00313.37
7.3.310.0030.00316.40
7.3.300.0040.00416.41
7.3.290.0000.00716.27
7.3.280.0090.00816.39
7.3.260.0110.00916.50
7.3.240.0100.01016.56
7.3.230.0190.00016.41
7.3.210.0080.00816.41
7.3.200.0060.01016.32
7.3.190.0090.00816.59
7.3.180.0150.00616.73
7.3.170.0120.00916.45
7.3.160.0090.00816.67
7.2.330.0130.00416.69
7.2.320.0100.00716.55
7.2.310.0090.00916.81
7.2.300.0060.01016.82
7.2.290.0130.01016.61
7.2.60.0070.00317.03
7.2.40.0730.01018.06
7.2.30.0760.01017.82
7.2.20.0920.00817.84
7.2.10.1440.01017.73
7.2.00.0670.00517.89
7.1.200.0030.01015.91
7.1.160.0620.01116.79
7.1.150.0880.00916.55
7.1.140.0880.00716.91
7.1.130.0950.00816.85
7.1.120.0650.00616.86
7.1.110.0780.01016.15
7.1.100.0580.01116.07
7.1.90.0560.01115.93
7.1.80.0680.00816.34
7.1.70.0800.00915.29
7.1.60.0800.00933.34
7.1.50.0890.01033.16
7.1.40.1010.01432.64
7.1.30.1130.01332.66
7.1.20.0920.00832.80
7.1.10.0790.00814.85
7.1.00.0850.01114.84

preferences:
35.59 ms | 403 KiB | 5 Q