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; } return concat_path_components($copy); } var_dump(path_relative_to("/a/b/c", "/a/bc"));

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.0180.00418.46
8.3.50.0060.01421.91
8.3.40.0040.01118.89
8.3.30.0040.01118.71
8.3.20.0000.00818.95
8.3.10.0000.00821.28
8.3.00.0070.00023.66
8.2.180.0100.01016.50
8.2.170.0080.00622.96
8.2.160.0070.00720.24
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0030.00519.36
8.2.110.0090.00022.32
8.2.100.0120.00017.84
8.2.90.0040.00419.14
8.2.80.0040.00417.97
8.2.70.0060.00317.63
8.2.60.0040.00717.80
8.2.50.0080.00018.07
8.2.40.0040.00418.34
8.2.30.0000.00819.84
8.2.20.0000.00717.82
8.2.10.0070.00017.67
8.2.00.0080.00317.66
8.1.280.0140.00025.92
8.1.270.0040.00423.99
8.1.260.0120.00626.35
8.1.250.0030.00528.09
8.1.240.0060.00322.59
8.1.230.0070.00320.97
8.1.220.0080.00018.77
8.1.210.0050.00318.87
8.1.200.0040.00417.22
8.1.190.0040.00417.39
8.1.180.0050.00318.10
8.1.170.0050.00318.48
8.1.160.0040.00418.95
8.1.150.0050.00318.62
8.1.140.0000.00817.46
8.1.130.0050.00317.80
8.1.120.0070.00017.37
8.1.110.0040.00417.43
8.1.100.0000.00817.37
8.1.90.0030.00317.52
8.1.80.0000.00717.46
8.1.70.0000.00717.46
8.1.60.0030.00517.59
8.1.50.0000.00817.39
8.1.40.0030.00617.50
8.1.30.0050.00317.69
8.1.20.0030.00517.52
8.1.10.0060.00317.64
8.1.00.0070.00317.41
8.0.300.0060.00319.80
8.0.290.0040.00417.18
8.0.280.0000.00718.37
8.0.270.0000.00717.32
8.0.260.0030.00316.71
8.0.250.0000.00716.84
8.0.240.0000.00916.87
8.0.230.0040.00416.89
8.0.220.0040.00416.86
8.0.210.0070.00016.81
8.0.200.0030.00316.88
8.0.190.0050.00316.93
8.0.180.0070.00016.91
8.0.170.0040.00416.97
8.0.160.0030.00316.79
8.0.150.0040.00416.82
8.0.140.0000.01116.76
8.0.130.0030.00313.42
8.0.120.0090.00115.07
8.0.110.0050.00515.12
8.0.100.0040.00615.14
8.0.90.0040.00715.17
8.0.80.0030.01415.09
8.0.70.0060.00415.03
8.0.60.0060.00415.06
8.0.50.0070.00315.06
8.0.30.0100.00815.89
8.0.20.0060.01216.08
8.0.10.0020.00515.26
8.0.00.0080.00715.59
7.4.330.0060.00014.65
7.4.320.0000.00916.60
7.4.300.0000.00616.64
7.4.290.0030.00316.56
7.4.280.0080.00016.50
7.4.270.0060.00016.63
7.4.260.0060.00013.29
7.4.250.0030.00414.87
7.4.240.0030.00314.95
7.4.230.0020.00414.80
7.4.220.0050.00914.90
7.4.210.0040.00915.90
7.4.200.0020.00514.96
7.4.190.0040.00414.89
7.4.180.0050.00013.36
7.4.160.0060.00514.98
7.4.150.0040.00715.33
7.4.140.0090.00616.30
7.4.130.0070.00515.49
7.4.120.0110.00515.47
7.4.110.0130.00214.83
7.4.100.0050.00714.89
7.4.90.0060.00514.90
7.4.80.0010.01016.31
7.4.70.0080.00714.72
7.4.60.0050.00614.92
7.4.50.0050.00414.65
7.4.40.0020.00717.65
7.4.30.0060.00614.80
7.4.20.0040.00413.11
7.4.10.0030.00313.47
7.4.00.0020.01014.01
7.3.330.0000.00513.40
7.3.320.0000.00613.24
7.3.310.0060.00214.76
7.3.300.0070.00114.73
7.3.290.0100.00314.85
7.3.280.0040.01115.52
7.3.270.0080.00815.38
7.3.260.0080.00616.60
7.3.250.0080.00815.31
7.3.240.0090.00414.93
7.3.230.0140.00114.87
7.3.220.0080.00013.33
7.3.210.0100.00314.72
7.3.200.0060.00716.35
7.3.190.0100.00314.81
7.3.180.0050.00714.99
7.3.170.0050.01014.89
7.3.160.0050.01014.85
7.3.150.0060.00313.15
7.3.140.0050.00213.13
7.3.130.0080.00013.13
7.3.120.0050.00714.16
7.3.110.0050.00313.17
7.3.100.0050.00513.23
7.3.90.0050.00313.54
7.3.80.0050.00213.32
7.3.70.0000.00813.51
7.3.60.0040.00213.32
7.3.50.0000.00613.34
7.3.40.0050.00213.52
7.3.30.0040.00413.45
7.3.20.0060.00315.26
7.3.10.0070.00315.90
7.3.00.0030.00416.00
7.2.340.0060.00613.46
7.2.330.0100.00715.02
7.2.320.0100.00815.05
7.2.310.0090.00715.11
7.2.300.0080.00815.17
7.2.290.0100.00715.13
7.2.280.0120.00313.46
7.2.270.0060.00613.32
7.2.260.0130.00013.44
7.2.250.0090.00513.38
7.2.240.0050.00913.32
7.2.230.0090.00413.48
7.2.220.0120.00013.54
7.2.210.0140.00013.55
7.2.200.0100.00613.61
7.2.190.0120.00013.39
7.2.180.0040.00813.56
7.2.170.0140.00013.61
7.2.160.0100.00313.45
7.2.150.0090.00415.36
7.2.140.0060.00815.44
7.2.130.0080.00516.23
7.2.120.0030.00916.25
7.2.110.0090.00516.24
7.2.100.0090.00516.33
7.2.90.0100.00116.17
7.2.80.0090.00516.11
7.2.70.0060.00616.21
7.2.60.0100.00316.08
7.2.50.0070.00416.11
7.2.40.0050.00716.28
7.2.30.0060.00616.28
7.2.20.0100.01016.19
7.2.10.0070.00616.25
7.2.00.0070.00717.00
7.1.330.0080.00414.41
7.1.320.0120.00014.40
7.1.310.0090.00314.38
7.1.300.0060.00614.23
7.1.290.0000.01314.43
7.1.280.0070.00714.25
7.1.270.0110.00214.21
7.1.260.0090.00414.12
7.1.250.0030.00914.95
7.1.240.0040.00814.20
7.1.230.0100.00314.23
7.1.220.0130.00014.21
7.1.210.0040.00914.18
7.1.200.0040.00814.21
7.1.190.0040.00814.47
7.1.180.0100.00314.32
7.1.170.0000.01414.14
7.1.160.0100.00314.30
7.1.150.0080.00514.15
7.1.140.0130.00014.11
7.1.130.0130.00014.35
7.1.120.0070.00514.16
7.1.110.0100.00314.35
7.1.100.0080.00416.16
7.1.90.0100.00314.34
7.1.80.0120.00014.43
7.1.70.0030.00815.52
7.1.60.0080.01016.93
7.1.50.0050.01115.70
7.1.40.0130.00014.28
7.1.30.0000.01214.35
7.1.20.0140.00014.22
7.1.10.0080.00414.34
7.1.00.0020.03918.40
7.0.330.0000.01214.10
7.0.320.0090.00214.02
7.0.310.0040.00814.07
7.0.300.0080.00514.22
7.0.290.0050.00714.25
7.0.280.0090.00414.07
7.0.270.0110.00214.27
7.0.260.0110.00014.23
7.0.250.0070.00514.34
7.0.240.0060.00614.39
7.0.230.0070.00514.25
7.0.220.0060.00614.30
7.0.210.0130.00014.10
7.0.200.0080.00215.60
7.0.190.0070.00514.07
7.0.180.0110.00014.17
7.0.170.0070.00614.38
7.0.160.0120.00014.19
7.0.150.0060.00614.25
7.0.140.0020.04318.01
7.0.130.0040.00814.41
7.0.120.0090.00314.30
7.0.110.0080.00614.28
7.0.100.0090.00414.28
7.0.90.0100.00314.18
7.0.80.0060.00614.09
7.0.70.0060.01817.93
7.0.60.0080.01517.95
7.0.50.0080.01718.07
7.0.40.0040.02017.17
7.0.30.0070.01717.15
7.0.20.0030.02117.09
7.0.10.0020.02417.18
7.0.00.0070.01817.02
5.6.400.0120.00012.87
5.6.390.0090.00312.70
5.6.380.0060.00612.74
5.6.370.0130.00012.69
5.6.360.0080.00512.79
5.6.350.0130.00012.70
5.6.340.0080.00412.50
5.6.330.0040.00812.88
5.6.320.0140.00012.73
5.6.310.0050.00512.86
5.6.300.0110.00012.45
5.6.290.0080.00312.71
5.6.280.0090.03516.75
5.6.270.0090.00312.58
5.6.260.0000.01212.73
5.6.250.0110.00012.56
5.6.240.0100.00312.52
5.6.230.0090.00312.82
5.6.220.0080.02216.78
5.6.210.0060.01716.67
5.6.200.0060.01917.06
5.6.190.0050.01816.99
5.6.180.0020.02016.92
5.6.170.0030.01816.89
5.6.160.0020.01817.03
5.6.150.0050.01516.94
5.6.140.0020.02117.04
5.6.130.0050.02016.96
5.6.120.0040.02616.98
5.6.110.0050.02016.94
5.6.100.0050.02716.87
5.6.90.0070.04016.94
5.6.80.0060.02816.63
5.6.70.0060.03216.72
5.6.60.0060.04216.64
5.6.50.0030.04516.44
5.6.40.0040.04216.63
5.6.30.0050.04116.54
5.6.20.0050.03016.61
5.6.10.0020.04516.49
5.6.00.0140.03116.73
5.5.380.0080.00412.91
5.5.370.0080.00512.89
5.5.360.0030.02016.69
5.5.350.0050.01816.54
5.5.340.0080.01516.79
5.5.330.0060.01716.90
5.5.320.0050.02016.71
5.5.310.0040.02416.76
5.5.300.0070.01716.73
5.5.290.0070.02016.77
5.5.280.0070.01816.77
5.5.270.0080.01716.79
5.5.260.0130.03816.72
5.5.250.0070.04116.80
5.5.240.0090.03716.38
5.5.230.0040.03716.42
5.5.220.0050.03216.57
5.5.210.0130.03216.62
5.5.200.0060.03216.51
5.5.190.0070.04016.48
5.5.180.0120.04016.39
5.5.170.0080.00512.64
5.5.160.0050.04316.51
5.5.150.0060.03416.36
5.5.140.0050.03216.44
5.5.130.0060.04016.38
5.5.120.0080.03516.32
5.5.110.0030.04416.28
5.5.100.0050.02816.49
5.5.90.0030.04116.40
5.5.80.0040.03416.29
5.5.70.0050.04516.51
5.5.60.0030.04316.42
5.5.50.0100.03816.37
5.5.40.0070.03916.38
5.5.30.0090.03216.32
5.5.20.0050.03816.51
5.5.10.0040.04516.53
5.5.00.0050.04216.43
5.4.450.0070.01816.11
5.4.440.0030.01915.91
5.4.430.0060.02416.14
5.4.420.0050.02016.06
5.4.410.0070.04016.00
5.4.400.0060.03015.70
5.4.390.0040.04016.00
5.4.380.0050.02615.85
5.4.370.0050.03715.84
5.4.360.0060.03516.01
5.4.350.0040.02815.96
5.4.340.0060.03815.75
5.4.330.0060.00612.81
5.4.320.0050.04415.91
5.4.310.0050.02815.83
5.4.300.0050.03915.88
5.4.290.0080.03215.92
5.4.280.0020.03415.89
5.4.270.0060.04115.85
5.4.260.0060.04515.78
5.4.250.0090.03715.89
5.4.240.0050.04315.94
5.4.230.0060.03815.72
5.4.220.0060.03515.67
5.4.210.0100.03515.72
5.4.200.0060.03615.74
5.4.190.0040.03815.69
5.4.180.0060.03915.84
5.4.170.0060.04015.84
5.4.160.0020.04215.80
5.4.150.0090.03915.85
5.4.140.0060.02814.60
5.4.130.0060.03614.55
5.4.120.0160.03114.56
5.4.110.0020.03614.62
5.4.100.0040.03014.61
5.4.90.0090.02114.74
5.4.80.0060.03314.56
5.4.70.0050.03814.54
5.4.60.0040.03814.66
5.4.50.0050.03614.60
5.4.40.0060.03614.51
5.4.30.0050.03314.60
5.4.20.0070.03714.65
5.4.10.0110.03014.50
5.4.00.0090.03213.99
5.3.290.0090.02814.03
5.3.280.0050.04213.93
5.3.270.0050.04213.86
5.3.260.0040.03914.00
5.3.250.0080.03113.98
5.3.240.0060.03113.80
5.3.230.0070.03213.97
5.3.220.0080.03613.80
5.3.210.0040.04313.93
5.3.200.0070.03713.94
5.3.190.0060.03713.97
5.3.180.0030.03514.03
5.3.170.0110.03513.89
5.3.160.0060.03514.03
5.3.150.0060.03214.02
5.3.140.0050.04013.98
5.3.130.0070.03513.93
5.3.120.0060.03813.97
5.3.110.0070.04013.96
5.3.100.0070.03713.93
5.3.90.0100.03713.99
5.3.80.0040.02613.79
5.3.70.0060.03513.79
5.3.60.0030.03513.88
5.3.50.0060.02313.85
5.3.40.0060.03813.85
5.3.30.0030.03313.92
5.3.20.0050.03713.96
5.3.10.0000.04213.72
5.3.00.0060.03813.74
5.2.170.0050.03313.33
5.2.160.0050.02813.36
5.2.150.0050.02813.25
5.2.140.0040.02213.17
5.2.130.0030.02413.31
5.2.120.0010.03313.18
5.2.110.0040.02813.20
5.2.100.0040.03413.22
5.2.90.0020.03813.19
5.2.80.0040.03213.18
5.2.70.0080.02813.15
5.2.60.0060.02813.24
5.2.50.0020.03113.32
5.2.40.0020.03213.18
5.2.30.0050.02613.25
5.2.20.0080.03013.08
5.2.10.0060.02713.06
5.2.00.0050.02213.03
5.1.60.0020.03112.81
5.1.50.0020.02512.86
5.1.40.0050.02712.79
5.1.30.0050.03012.82
5.1.20.0040.02912.86
5.1.10.0030.03012.83
5.1.00.0000.03112.77
5.0.50.0020.02512.63
5.0.40.0050.01712.63
5.0.30.0040.02412.63
5.0.20.0070.01312.63
5.0.10.0040.02412.63
5.0.00.0050.03312.63
4.4.90.0000.01512.63
4.4.80.0030.01712.63
4.4.70.0030.01512.63
4.4.60.0020.01312.63
4.4.50.0020.01512.63
4.4.40.0000.02912.63
4.4.30.0030.01912.63
4.4.20.0040.01412.63
4.4.10.0000.02012.63
4.4.00.0020.02512.63
4.3.110.0050.01512.63
4.3.100.0000.01312.63
4.3.90.0020.01712.63
4.3.80.0000.02912.63
4.3.70.0040.01312.63
4.3.60.0040.01312.63
4.3.50.0020.01712.63
4.3.40.0020.02512.63
4.3.30.0050.01512.63
4.3.20.0010.01512.63
4.3.10.0000.01812.63
4.3.00.0010.01712.63

preferences:
41.41 ms | 401 KiB | 5 Q