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; } if ($i == count($rel_components)) return concat_path_components($copy); else return NULL; } 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.0120.00318.55
8.3.50.0110.00821.89
8.3.40.0140.00318.83
8.3.30.0140.00418.86
8.3.20.0040.00420.16
8.3.10.0040.00423.56
8.3.00.0050.00220.64
8.2.180.0110.00716.88
8.2.170.0070.00722.96
8.2.160.0080.00818.60
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00821.00
8.2.110.0030.00622.20
8.2.100.0060.00617.84
8.2.90.0090.00019.41
8.2.80.0080.00018.16
8.2.70.0030.00617.38
8.2.60.0030.00717.78
8.2.50.0060.00318.07
8.2.40.0000.00718.16
8.2.30.0040.00418.13
8.2.20.0000.00817.61
8.2.10.0000.00717.76
8.2.00.0000.00817.78
8.1.280.0140.00025.92
8.1.270.0040.00423.90
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.92
8.1.230.0070.00319.10
8.1.220.0060.00317.74
8.1.210.0050.00318.77
8.1.200.0030.00617.25
8.1.190.0050.00317.43
8.1.180.0030.00618.10
8.1.170.0040.00418.71
8.1.160.0070.00321.95
8.1.150.0000.00718.66
8.1.140.0000.00717.46
8.1.130.0000.00717.88
8.1.120.0000.00717.49
8.1.110.0080.00317.45
8.1.100.0030.00317.46
8.1.90.0000.00717.53
8.1.80.0040.00417.44
8.1.70.0030.00317.45
8.1.60.0040.00417.64
8.1.50.0080.00017.60
8.1.40.0040.00417.46
8.1.30.0050.00317.65
8.1.20.0000.00817.66
8.1.10.0040.00417.52
8.1.00.0040.00417.50
8.0.300.0080.00018.77
8.0.290.0070.00017.18
8.0.280.0030.00518.51
8.0.270.0030.00317.27
8.0.260.0000.00816.82
8.0.250.0070.00016.85
8.0.240.0000.00716.97
8.0.230.0000.00716.94
8.0.220.0000.00616.79
8.0.210.0000.00716.79
8.0.200.0030.00316.98
8.0.190.0000.00817.02
8.0.180.0000.00716.85
8.0.170.0080.00016.93
8.0.160.0030.00516.79
8.0.150.0040.00416.82
8.0.140.0070.00016.88
8.0.130.0000.00613.33
8.0.120.0040.00415.06
8.0.110.0060.00415.09
8.0.100.0080.00215.09
8.0.90.0030.00715.07
8.0.80.0080.00715.14
8.0.70.0030.00515.06
8.0.60.0010.00615.15
8.0.50.0050.00215.10
8.0.30.0110.00715.70
8.0.20.0070.00916.05
8.0.10.0040.00415.21
8.0.00.0050.01215.59
7.4.330.0030.00315.00
7.4.320.0070.00016.66
7.4.300.0000.00616.61
7.4.290.0000.00716.62
7.4.280.0050.00316.44
7.4.270.0030.00616.62
7.4.260.0000.00616.59
7.4.250.0030.00514.89
7.4.240.0020.00615.49
7.4.230.0060.00214.97
7.4.220.0050.00914.99
7.4.210.0060.00815.71
7.4.200.0030.00414.85
7.4.190.0000.00815.04
7.4.180.0040.00213.34
7.4.160.0000.01214.96
7.4.150.0050.00715.31
7.4.140.0040.01016.30
7.4.130.0080.00515.41
7.4.120.0080.00615.47
7.4.110.0080.00814.84
7.4.100.0070.00514.96
7.4.90.0060.00714.87
7.4.80.0080.00714.85
7.4.70.0040.01014.78
7.4.60.0080.00514.88
7.4.50.0060.00314.75
7.4.40.0060.00617.97
7.4.30.0070.00914.89
7.4.20.0090.00013.27
7.4.10.0070.00313.23
7.4.00.0080.00414.10
7.3.330.0030.00313.38
7.3.320.0040.00413.45
7.3.310.0050.00314.72
7.3.300.0050.00314.85
7.3.290.0060.00514.73
7.3.280.0100.00615.60
7.3.270.0110.00315.40
7.3.260.0080.00514.82
7.3.250.0050.01115.31
7.3.240.0080.00614.81
7.3.230.0100.00714.82
7.3.220.0040.00413.08
7.3.210.0120.00314.82
7.3.200.0060.00716.33
7.3.190.0040.00814.86
7.3.180.0070.00514.85
7.3.170.0050.00714.82
7.3.160.0050.00714.96
7.3.150.0000.00713.37
7.3.140.0000.00713.34
7.3.130.0060.00013.21
7.3.120.0040.00713.99
7.3.110.0000.00713.23
7.3.100.0000.00613.25
7.3.90.0000.00713.54
7.3.80.0000.00813.08
7.3.70.0040.00313.41
7.3.60.0050.00313.49
7.3.50.0040.00213.53
7.3.40.0060.00013.51
7.3.30.0020.00513.25
7.3.20.0040.00415.21
7.3.10.0000.01015.70
7.3.00.0010.00615.84
7.2.340.0060.00613.49
7.2.330.0090.00714.92
7.2.320.0070.00814.96
7.2.310.0110.00615.08
7.2.300.0100.00515.06
7.2.290.0090.00614.98
7.2.280.0060.00613.48
7.2.270.0040.00813.28
7.2.260.0130.00013.39
7.2.250.0070.00613.46
7.2.240.0050.00713.54
7.2.230.0080.00413.32
7.2.220.0090.00513.40
7.2.210.0120.00013.45
7.2.200.0140.00013.56
7.2.190.0050.00713.61
7.2.180.0100.00313.46
7.2.170.0120.00013.55
7.2.160.0080.00413.62
7.2.150.0130.00015.18
7.2.140.0130.00015.46
7.2.130.0080.00616.07
7.2.120.0130.00016.13
7.2.110.0120.00516.21
7.2.100.0110.00516.15
7.2.90.0060.00616.05
7.2.80.0090.00416.18
7.2.70.0070.00616.04
7.2.60.0070.00616.13
7.2.50.0060.01016.17
7.2.40.0060.00616.06
7.2.30.0080.00516.21
7.2.20.0020.01116.21
7.2.10.0030.01116.17
7.2.00.0090.00417.28
7.1.330.0080.00414.24
7.1.320.0100.00214.29
7.1.310.0090.00214.29
7.1.300.0120.00014.38
7.1.290.0040.00814.25
7.1.280.0090.00214.42
7.1.270.0110.00014.29
7.1.260.0000.01214.22
7.1.250.0050.00514.99
7.1.240.0120.00014.33
7.1.230.0080.00414.41
7.1.220.0000.01214.29
7.1.210.0060.00614.28
7.1.200.0080.00414.29
7.1.190.0060.00614.19
7.1.180.0000.01114.33
7.1.170.0110.00014.27
7.1.160.0120.00014.14
7.1.150.0120.00014.29
7.1.140.0100.00314.19
7.1.130.0090.00314.36
7.1.120.0120.00014.32
7.1.110.0100.00214.34
7.1.100.0080.00416.14
7.1.90.0060.00614.20
7.1.80.0060.00614.30
7.1.70.0050.00615.44
7.1.60.0110.00416.79
7.1.50.0050.01115.65
7.1.40.0090.00314.48
7.1.30.0080.00414.42
7.1.20.0090.00314.34
7.1.10.0090.00314.16
7.1.00.0060.03818.20
7.0.330.0060.00614.19
7.0.320.0110.00014.10
7.0.310.0070.00414.22
7.0.300.0070.00514.30
7.0.290.0120.00014.19
7.0.280.0000.01114.16
7.0.270.0120.00014.23
7.0.260.0000.01114.13
7.0.250.0120.00014.39
7.0.240.0090.00314.39
7.0.230.0060.00614.30
7.0.220.0060.00614.25
7.0.210.0120.00014.30
7.0.200.0100.00215.53
7.0.190.0120.00014.20
7.0.180.0080.00414.27
7.0.170.0110.00014.39
7.0.160.0080.00414.27
7.0.150.0060.00614.06
7.0.140.0020.04218.10
7.0.130.0080.00414.23
7.0.120.0060.00614.33
7.0.110.0040.00814.25
7.0.100.0090.02717.03
7.0.90.0210.03817.04
7.0.80.0160.02417.07
7.0.70.0080.04617.16
7.0.60.0060.02517.16
7.0.50.0070.04217.21
7.0.40.0060.02617.25
7.0.30.0080.04117.17
7.0.20.0140.04317.17
7.0.10.0060.04317.15
7.0.00.0070.03217.04
5.6.400.0110.00012.88
5.6.390.0080.00412.70
5.6.380.0120.00012.69
5.6.370.0080.00412.67
5.6.360.0090.00212.82
5.6.350.0060.00612.78
5.6.340.0110.00012.50
5.6.330.0050.00512.50
5.6.320.0080.00412.89
5.6.310.0060.00612.58
5.6.300.0050.00512.49
5.6.290.0080.00412.88
5.6.280.0060.03816.85
5.6.270.0070.00412.61
5.6.260.0030.00712.52
5.6.250.0060.02616.67
5.6.240.0070.02516.76
5.6.230.0040.03216.70
5.6.220.0120.03816.71
5.6.210.0110.03316.73
5.6.200.0030.04717.07
5.6.190.0120.03517.11
5.6.180.0060.03016.96
5.6.170.0190.03617.00
5.6.160.0070.02216.89
5.6.150.0060.02517.06
5.6.140.0080.02116.93
5.6.130.0070.02216.94
5.6.120.0020.03017.01
5.6.110.0030.02616.91
5.6.100.0080.02116.84
5.6.90.0060.02316.87
5.6.80.0070.03016.63
5.6.70.0050.03916.75
5.6.60.0030.02316.74
5.6.50.0080.03616.61
5.6.40.0100.03716.47
5.6.30.0080.01716.67
5.6.20.0090.03116.66
5.6.10.0080.02516.70
5.6.00.0100.03416.50
5.5.380.0080.04316.72
5.5.370.0060.04516.81
5.5.360.0100.04016.59
5.5.350.0060.04016.61
5.5.340.0050.04816.65
5.5.330.0110.02316.88
5.5.320.0060.02516.71
5.5.310.0060.04716.86
5.5.300.0090.02516.81
5.5.290.0060.02316.68
5.5.280.0070.02516.86
5.5.270.0080.02016.71
5.5.260.0080.02216.83
5.5.250.0050.02316.76
5.5.240.0060.02116.44
5.5.230.0080.02316.34
5.5.220.0080.01916.43
5.5.210.0080.02116.38
5.5.200.0140.03516.31
5.5.190.0070.04016.41
5.5.180.0060.03316.34
5.5.170.0070.00412.65
5.5.160.0070.01816.40
5.5.150.0080.01816.48
5.5.140.0060.02116.32
5.5.130.0030.02516.28
5.5.120.0090.01816.18
5.5.110.0020.02616.31
5.5.100.0050.02216.38
5.5.90.0090.02316.39
5.5.80.0090.01816.43
5.5.70.0050.02316.51
5.5.60.0090.01516.42
5.5.50.0060.02116.46
5.5.40.0030.01916.40
5.5.30.0030.02216.49
5.5.20.0030.02016.36
5.5.10.0090.02216.32
5.5.00.0060.02116.46
5.4.450.0060.02115.85
5.4.440.0030.03316.02
5.4.430.0040.02616.22
5.4.420.0080.01716.10
5.4.410.0040.02315.88
5.4.400.0030.02315.86
5.4.390.0060.02215.93
5.4.380.0060.03415.89
5.4.370.0060.02115.93
5.4.360.0090.03915.96
5.4.350.0030.02415.93
5.4.340.0040.03115.79
5.4.330.0080.00312.67
5.4.320.0120.01515.94
5.4.310.0080.01915.82
5.4.300.0060.02615.98
5.4.290.0090.01815.98
5.4.280.0050.02015.74
5.4.270.0060.02015.91
5.4.260.0050.02115.96
5.4.250.0040.02215.68
5.4.240.0090.01715.90
5.4.230.0050.02115.85
5.4.220.0040.02015.69
5.4.210.0040.02215.73
5.4.200.0060.02015.82
5.4.190.0040.02115.83
5.4.180.0050.02115.79
5.4.170.0070.01715.89
5.4.160.0100.02015.73
5.4.150.0030.02515.70
5.4.140.0040.02214.57
5.4.130.0060.01914.57
5.4.120.0060.01914.60
5.4.110.0070.03014.48
5.4.100.0060.03514.63
5.4.90.0040.03914.56
5.4.80.0090.02714.58
5.4.70.0100.03514.59
5.4.60.0060.03814.65
5.4.50.0110.03514.57
5.4.40.0070.02314.63
5.4.30.0030.04214.62
5.4.20.0080.02214.46
5.4.10.0090.03714.63
5.4.00.0090.03714.23
5.3.290.0090.01713.92
5.3.280.0070.02013.84
5.3.270.0060.01913.75
5.3.260.0050.02113.82
5.3.250.0040.02213.96
5.3.240.0030.02213.88
5.3.230.0060.02113.91
5.3.220.0070.01513.71
5.3.210.0080.01813.73
5.3.200.0100.03713.88
5.3.190.0050.04013.71
5.3.180.0090.03013.78
5.3.170.0070.02413.94
5.3.160.0070.04013.89
5.3.150.0040.03913.81
5.3.140.0070.03813.73
5.3.130.0050.02813.71
5.3.120.0020.03713.71
5.3.110.0070.03813.77
5.3.100.0070.03913.54
5.3.90.0070.03813.66
5.3.80.0110.03613.45
5.3.70.0140.03013.39
5.3.60.0060.04113.61
5.3.50.0070.03713.45
5.3.40.0070.03813.45
5.3.30.0070.04013.56
5.3.20.0090.02513.50
5.3.10.0050.02413.21
5.3.00.0140.02813.19
5.2.170.0110.02811.72
5.2.160.0090.03011.69
5.2.150.0050.03411.65
5.2.140.0060.02811.64
5.2.130.0040.03711.66
5.2.120.0080.02711.76
5.2.110.0020.03611.66
5.2.100.0100.02811.79
5.2.90.0020.02111.66
5.2.80.0050.03311.74
5.2.70.0070.03011.66
5.2.60.0030.02311.72
5.2.50.0060.02511.76
5.2.40.0110.02111.62
5.2.30.0060.01811.75
5.2.20.0050.03311.55
5.2.10.0060.03011.65
5.2.00.0010.02311.54
5.1.60.0060.02611.29
5.1.50.0050.02911.32
5.1.40.0050.01811.37
5.1.30.0070.02811.28
5.1.20.0050.02311.32
5.1.10.0040.02811.19
5.1.00.0110.02111.23
5.0.50.0050.02211.09
5.0.40.0000.02211.09
5.0.30.0050.03111.09
5.0.20.0070.02011.09
5.0.10.0040.01311.09
5.0.00.0020.02911.09
4.4.90.0050.01211.09
4.4.80.0020.01811.09
4.4.70.0000.01211.09
4.4.60.0030.01811.09
4.4.50.0050.01511.09
4.4.40.0020.02511.09
4.4.30.0050.01511.09
4.4.20.0050.01511.09
4.4.10.0030.01811.09
4.4.00.0050.02211.09
4.3.110.0020.01811.09
4.3.100.0050.01511.09
4.3.90.0040.01711.09
4.3.80.0070.02311.09
4.3.70.0020.01311.09
4.3.60.0000.02011.09
4.3.50.0040.01311.09
4.3.40.0040.01811.09
4.3.30.0000.02011.09
4.3.20.0030.01311.09
4.3.10.0030.01211.09
4.3.00.0000.01111.09

preferences:
52.9 ms | 401 KiB | 5 Q