3v4l.org

run code in 300+ PHP versions simultaneously
<?php function concat_path_components($path_components) { $first_component = array_shift($path_components); if ($first_component == NULL) return ""; return array_reduce( $path_components, function ($path, $path_component) { return $path . DIRECTORY_SEPARATOR . $path_component; }, $first_component); } function path_components($path) { $components = array(); while ($path != "." && $path != "/") { array_unshift($components, basename($path)); $path = dirname($path); } if ($path == "/") array_unshift($components, "/"); return $components; } function path_relative_to($path, $rel) { $path_components = path_components($path); $copy = $path_components; $rel_components = path_components($rel); for($i = 0 ; $i < count($rel_components) ; ++$i) { if ($path_components[$i] == $rel[$i]) array_shift($copy); else break; } echo $i . " " . count($rel_components) . PHP_EOL; if ($i == count($rel_components)) return concat_path_components($copy); else return NULL; } var_dump(path_relative_to("/a/b/c", "/a/b"));

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.0070.01416.50
8.3.50.0220.00816.34
8.3.40.0120.00618.82
8.3.30.0110.01118.67
8.3.20.0040.00418.49
8.3.10.0040.00420.66
8.3.00.0080.00019.51
8.2.180.0130.01016.63
8.2.170.0110.00722.96
8.2.160.0070.00721.24
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0030.00526.16
8.2.120.0050.00320.90
8.2.110.0040.00421.00
8.2.100.0080.00617.90
8.2.90.0030.00619.42
8.2.80.0000.00819.39
8.2.70.0000.00917.75
8.2.60.0000.01018.05
8.2.50.0060.00318.07
8.2.40.0000.00818.22
8.2.30.0060.00318.24
8.2.20.0030.00617.74
8.2.10.0040.00417.77
8.2.00.0000.00817.80
8.1.280.0160.00625.92
8.1.270.0000.00724.66
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0000.00922.61
8.1.230.0040.00820.91
8.1.220.0040.00417.76
8.1.210.0000.00818.95
8.1.200.0040.00417.35
8.1.190.0040.00417.40
8.1.180.0040.00418.10
8.1.170.0080.00018.85
8.1.160.0030.00618.93
8.1.150.0080.00018.57
8.1.140.0070.00017.45
8.1.130.0000.00717.75
8.1.120.0040.00417.51
8.1.110.0020.00517.52
8.1.100.0000.00717.45
8.1.90.0000.00717.39
8.1.80.0040.00417.47
8.1.70.0070.00017.50
8.1.60.0030.00617.59
8.1.50.0080.00017.53
8.1.40.0000.00817.53
8.1.30.0030.00617.62
8.1.20.0050.00317.68
8.1.10.0040.00417.58
8.1.00.0000.00717.47
8.0.300.0040.00420.03
8.0.290.0000.00716.73
8.0.280.0050.00318.41
8.0.270.0000.00717.19
8.0.260.0030.00316.94
8.0.250.0000.00816.87
8.0.240.0100.00016.87
8.0.230.0000.00716.96
8.0.220.0080.00016.93
8.0.210.0000.00716.81
8.0.200.0000.00616.98
8.0.190.0000.00816.88
8.0.180.0040.00416.86
8.0.170.0040.00416.91
8.0.160.0000.00817.01
8.0.150.0000.01016.95
8.0.140.0060.00316.88
8.0.130.0000.00513.34
8.0.120.0010.00515.16
8.0.110.0040.00415.12
8.0.100.0050.00215.04
8.0.90.0030.00615.13
8.0.80.0070.00515.09
8.0.70.0040.00415.11
8.0.60.0050.00315.18
8.0.50.0010.00615.13
8.0.30.0100.00815.99
8.0.20.0090.00815.91
8.0.10.0000.00815.27
8.0.00.0080.00815.77
7.4.330.0000.00513.00
7.4.320.0030.00316.71
7.4.300.0030.00316.52
7.4.290.0030.00316.67
7.4.280.0000.00716.54
7.4.270.0030.00316.42
7.4.260.0000.00513.36
7.4.250.0040.00514.91
7.4.240.0030.00515.51
7.4.230.0030.00414.97
7.4.220.0100.00315.00
7.4.210.0070.00715.95
7.4.200.0050.00314.85
7.4.190.0020.00615.00
7.4.180.0040.00313.42
7.4.160.0100.00214.90
7.4.150.0110.00514.92
7.4.140.0040.00915.42
7.4.130.0090.00715.40
7.4.120.0090.00715.37
7.4.110.0070.00614.83
7.4.100.0110.00514.88
7.4.90.0090.00714.89
7.4.80.0080.00716.33
7.4.70.0100.00314.90
7.4.60.0110.00514.87
7.4.50.0100.00114.87
7.4.40.0080.00714.73
7.4.30.0010.01114.78
7.4.20.0040.00413.23
7.4.10.0050.00513.38
7.4.00.0070.00713.99
7.3.330.0060.00013.25
7.3.320.0050.00013.39
7.3.310.0040.00514.84
7.3.300.0030.00514.77
7.3.290.0070.00614.86
7.3.280.0070.00715.59
7.3.270.0070.00914.88
7.3.260.0090.00714.81
7.3.250.0070.00815.37
7.3.240.0090.00414.87
7.3.230.0080.00714.89
7.3.220.0070.00513.29
7.3.210.0090.00514.85
7.3.200.0050.00814.79
7.3.190.0070.00814.83
7.3.180.0080.00414.79
7.3.170.0040.01014.84
7.3.160.0090.00414.73
7.3.150.0070.00013.13
7.3.140.0070.00013.35
7.3.130.0060.00013.07
7.3.120.0050.00513.84
7.3.110.0000.00613.02
7.3.100.0070.00313.12
7.3.90.0030.00313.51
7.3.80.0000.00513.31
7.3.70.0060.00013.40
7.3.60.0000.00713.36
7.3.50.0070.00013.37
7.3.40.0000.00713.50
7.3.30.0070.00013.52
7.3.20.0000.00715.15
7.3.10.0030.00615.99
7.3.00.0020.00815.99
7.2.340.0120.00013.42
7.2.330.0110.00515.13
7.2.320.0070.01015.18
7.2.310.0080.00714.98
7.2.300.0070.00915.03
7.2.290.0110.00314.98
7.2.280.0060.00613.47
7.2.270.0100.00313.40
7.2.260.0070.00613.25
7.2.250.0100.00313.45
7.2.240.0040.00813.33
7.2.230.0030.00913.49
7.2.220.0080.00413.33
7.2.210.0090.00313.40
7.2.200.0110.00313.50
7.2.190.0130.00013.59
7.2.180.0070.00613.36
7.2.170.0080.00413.61
7.2.160.0060.00613.64
7.2.150.0070.00715.29
7.2.140.0090.00515.20
7.2.130.0110.00316.22
7.2.120.0070.00616.31
7.2.110.0110.00216.08
7.2.100.0060.00616.04
7.2.90.0060.00816.21
7.2.80.0070.00616.24
7.2.70.0090.00516.10
7.2.60.0090.00616.09
7.2.50.0090.00316.13
7.2.40.0070.00616.16
7.2.30.0080.00416.23
7.2.20.0090.00616.25
7.2.10.0100.00516.13
7.2.00.0060.00717.39
7.1.330.0090.00214.41
7.1.320.0110.00014.29
7.1.310.0110.00014.36
7.1.300.0120.00014.38
7.1.290.0000.01114.18
7.1.280.0120.00014.41
7.1.270.0060.00614.12
7.1.260.0090.00314.22
7.1.250.0100.00214.93
7.1.240.0090.00414.31
7.1.230.0000.01114.35
7.1.220.0120.00014.39
7.1.210.0080.00414.25
7.1.200.0120.00014.32
7.1.190.0070.00514.39
7.1.180.0120.00014.15
7.1.170.0100.00214.22
7.1.160.0120.00014.34
7.1.150.0080.00414.29
7.1.140.0000.01314.22
7.1.130.0090.00314.20
7.1.120.0100.00314.30
7.1.110.0080.00414.28
7.1.100.0060.00516.23
7.1.90.0120.00014.32
7.1.80.0110.00014.36
7.1.70.0090.00715.45
7.1.60.0120.00716.84
7.1.50.0080.00615.71
7.1.40.0150.00014.40
7.1.30.0040.00914.24
7.1.20.0130.00014.34
7.1.10.0120.00014.16
7.1.00.0020.02218.22
7.0.330.0090.00414.06
7.0.320.0090.00414.17
7.0.310.0110.00014.05
7.0.300.0080.00314.19
7.0.290.0120.00014.05
7.0.280.0090.00214.21
7.0.270.0090.00314.20
7.0.260.0120.00014.17
7.0.250.0100.00314.28
7.0.240.0080.00414.32
7.0.230.0040.00814.21
7.0.220.0120.00014.30
7.0.210.0090.00214.31
7.0.200.0100.00515.60
7.0.190.0080.00514.33
7.0.180.0070.00514.33
7.0.170.0110.00014.39
7.0.160.0120.00814.12
7.0.150.0090.00314.32
7.0.140.0080.03718.10
7.0.130.0120.00014.36
7.0.120.0080.03718.23
7.0.110.0120.00014.33
7.0.100.0110.00014.29
7.0.90.0140.00014.06
7.0.80.0080.00414.02
7.0.70.0110.00014.15
7.0.60.0070.04417.12
7.0.50.0110.02316.01
7.0.40.0110.04017.07
7.0.30.0190.02817.14
7.0.20.0180.04317.20
7.0.10.0060.02917.08
7.0.00.0120.03317.24
5.6.400.0080.00312.86
5.6.390.0060.00612.86
5.6.380.0070.00512.64
5.6.370.0090.00312.78
5.6.360.0060.00612.76
5.6.350.0120.00012.94
5.6.340.0120.00012.83
5.6.330.0040.00812.90
5.6.320.0080.00312.90
5.6.310.0080.00412.94
5.6.300.0070.00412.75
5.6.290.0060.00612.75
5.6.280.0080.03616.90
5.6.270.0080.00312.78
5.6.260.0040.00712.95
5.6.250.0060.00612.94
5.6.240.0110.00012.65
5.6.230.0090.00312.77
5.6.220.0080.00412.78
5.6.210.0050.02816.65
5.6.200.0120.03915.66
5.6.190.0060.02316.64
5.6.180.0180.02816.65
5.6.170.0250.02416.85
5.6.160.0110.03516.72
5.6.150.0060.02315.58
5.6.140.0070.02515.50
5.6.130.0060.02515.54
5.6.120.0040.04916.88
5.6.110.0130.03916.99
5.6.100.0020.03916.97
5.6.90.0000.05216.85
5.6.80.0120.03716.58
5.6.70.0110.00012.96
5.6.60.0050.00512.86
5.6.50.0070.00412.71
5.6.40.0100.00012.85
5.6.30.0000.01012.62
5.6.20.0050.00512.75
5.6.10.0060.00612.55
5.6.00.0110.00012.93
5.5.380.0090.00213.13
5.5.370.0110.00012.73
5.5.360.0090.00312.54
5.5.350.0070.03316.66
5.5.340.0080.04115.48
5.5.330.0060.02516.58
5.5.320.0160.02216.52
5.5.310.0170.02816.64
5.5.300.0070.04215.49
5.5.290.0070.02415.46
5.5.280.0100.03316.76
5.5.270.0130.03816.78
5.5.260.0070.02516.71
5.5.250.0090.04016.65
5.5.240.0160.03716.52
5.5.230.0060.00412.82
5.5.220.0080.00212.80
5.5.210.0050.00512.75
5.5.200.0060.00412.86
5.5.190.0070.00412.51
5.5.180.0040.00712.86
5.5.170.0040.00812.72
5.5.160.0050.00512.56
5.5.150.0100.00012.45
5.5.140.0090.00312.38
5.5.130.0110.00012.38
5.5.120.0090.00212.73
5.5.110.0070.00512.66
5.5.100.0090.00212.84
5.5.90.0100.00012.84
5.5.80.0070.00412.80
5.5.70.0060.00612.66
5.5.60.0110.00012.90
5.5.50.0110.00012.64
5.5.40.0030.00712.72
5.5.30.0110.00012.99
5.5.20.0100.00012.68
5.5.10.0100.00012.57
5.5.00.0100.00012.76
5.4.450.0050.02316.18
5.4.440.0130.03716.18
5.4.430.0070.03816.11
5.4.420.0080.04216.06
5.4.410.0120.03516.10
5.4.400.0110.03715.99
5.4.390.0100.03716.02
5.4.380.0040.04315.98
5.4.370.0100.03715.79
5.4.360.0060.04315.87
5.4.350.0060.04115.86
5.4.340.0050.04515.93
5.4.330.0120.00012.73
5.4.320.0090.04115.98
5.4.310.0070.03016.00
5.4.300.0090.03015.89
5.4.290.0050.02316.09
5.4.280.0080.03315.89
5.4.270.0090.03816.03
5.4.260.0080.02815.99
5.4.250.0080.03815.81
5.4.240.0090.04016.02
5.4.230.0100.03515.89
5.4.220.0090.03815.89
5.4.210.0070.04015.88
5.4.200.0090.01915.88
5.4.190.0120.03315.85
5.4.180.0060.03315.67
5.4.170.0070.02915.83
5.4.160.0080.03915.81
5.4.150.0070.04015.72
5.4.140.0110.03614.72
5.4.130.0050.03314.66
5.4.120.0060.03814.59
5.4.110.0060.02914.65
5.4.100.0050.04014.46
5.4.90.0050.03714.56
5.4.80.0050.03714.67
5.4.70.0030.02314.70
5.4.60.0050.04014.62
5.4.50.0100.02314.52
5.4.40.0110.03614.59
5.4.30.0070.03314.61
5.4.20.0050.03814.56
5.4.10.0170.03014.51
5.4.00.0090.03314.09
5.3.290.0020.04713.99
5.3.280.0110.03813.87
5.3.270.0110.03613.87
5.3.260.0090.02813.80
5.3.250.0090.04013.89
5.3.240.0090.02313.88
5.3.230.0060.04013.79
5.3.220.0080.02413.77
5.3.210.0060.04013.71
5.3.200.0080.04113.77
5.3.190.0060.04313.79
5.3.180.0070.04013.74
5.3.170.0090.02713.83
5.3.160.0080.03813.90
5.3.150.0070.04213.91
5.3.140.0100.02013.77
5.3.130.0080.04113.75
5.3.120.0120.02413.90
5.3.110.0090.03813.83
5.3.100.0050.03513.60
5.3.90.0090.03513.47
5.3.80.0050.02713.60
5.3.70.0080.02913.49
5.3.60.0070.03213.63
5.3.50.0080.03813.57
5.3.40.0090.03013.45
5.3.30.0040.04113.63
5.3.20.0060.02813.38
5.3.10.0140.03113.31
5.3.00.0070.03313.32
5.2.170.0070.03111.59
5.2.160.0040.02111.48
5.2.150.0040.01711.45
5.2.140.0060.02811.47
5.2.130.0050.03111.43
5.2.120.0070.03011.36
5.2.110.0070.03411.33
5.2.100.0030.02811.44
5.2.90.0060.02211.33
5.2.80.0080.02111.39
5.2.70.0020.02011.29
5.2.60.0050.01811.24
5.2.50.0030.03611.50
5.2.40.0040.03511.44
5.2.30.0070.03211.27
5.2.20.0060.02311.19
5.2.10.0060.02711.13
5.2.00.0060.02611.06
5.1.60.0020.03210.35
5.1.50.0050.02810.37
5.1.40.0050.02810.34
5.1.30.0060.01610.73
5.1.20.0070.01710.50
5.1.10.0060.03010.40
5.1.00.0070.02810.25
5.0.50.0040.0269.52
5.0.40.0050.0229.45
5.0.30.0030.0359.35
5.0.20.0050.0229.37
5.0.10.0050.0229.40
5.0.00.0050.0329.32
4.4.90.0020.0109.19
4.4.80.0010.0199.19
4.4.70.0020.0209.19
4.4.60.0020.0209.19
4.4.50.0020.0189.19
4.4.40.0020.0309.19
4.4.30.0030.0199.19
4.4.20.0010.0189.19
4.4.10.0020.0209.19
4.4.00.0030.0289.19
4.3.110.0030.0129.19
4.3.100.0030.0149.19
4.3.90.0020.0159.19
4.3.80.0040.0239.19
4.3.70.0010.0099.19
4.3.60.0020.0089.19
4.3.50.0020.0209.19
4.3.40.0030.0259.19
4.3.30.0010.0089.19
4.3.20.0010.0099.19
4.3.10.0000.0169.19
4.3.00.0000.0189.19

preferences:
47.34 ms | 401 KiB | 5 Q