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); if ($i == count($rel_components) -1) return concat_path_components($copy); else return ""; } 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.40.0110.00418.61
8.3.30.0090.00619.04
8.3.20.0080.00020.39
8.3.10.0000.00822.10
8.3.00.0040.00422.41
8.2.170.0080.00622.96
8.2.160.0100.00319.07
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0140.00026.16
8.2.120.0030.00519.36
8.2.110.0030.00620.40
8.2.100.0120.00017.78
8.2.90.0040.00419.36
8.2.80.0000.00817.97
8.2.70.0030.00517.75
8.2.60.0000.00817.91
8.2.50.0060.00618.07
8.2.40.0040.00420.00
8.2.30.0000.00718.14
8.2.20.0050.00317.77
8.2.10.0040.00417.73
8.2.00.0040.00417.76
8.1.270.0080.00022.19
8.1.260.0090.00026.35
8.1.250.0000.00728.09
8.1.240.0000.00922.02
8.1.230.0070.00320.87
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0040.00417.43
8.1.180.0000.00918.73
8.1.170.0040.00418.47
8.1.160.0000.00722.08
8.1.150.0040.00418.54
8.1.140.0070.00417.39
8.1.130.0030.00317.70
8.1.120.0000.00817.52
8.1.110.0070.00017.54
8.1.100.0000.00817.50
8.1.90.0000.00717.47
8.1.80.0000.00717.45
8.1.70.0040.00417.49
8.1.60.0060.00317.61
8.1.50.0050.00217.50
8.1.40.0040.00417.46
8.1.30.0040.00417.63
8.1.20.0040.00417.73
8.1.10.0000.00817.59
8.1.00.0030.00617.40
8.0.300.0050.00218.77
8.0.290.0000.00717.05
8.0.280.0000.00718.48
8.0.270.0000.00717.35
8.0.260.0030.00316.75
8.0.250.0030.00316.95
8.0.240.0070.00016.93
8.0.230.0040.00416.88
8.0.220.0000.00816.89
8.0.210.0030.00516.93
8.0.200.0030.00316.95
8.0.190.0070.00017.00
8.0.180.0070.00016.95
8.0.170.0040.00416.95
8.0.160.0000.00717.01
8.0.150.0030.00316.74
8.0.140.0040.00316.79
8.0.130.0000.00513.30
8.0.120.0050.00515.06
8.0.110.0080.00215.11
8.0.100.0050.00515.06
8.0.90.0040.00515.13
8.0.80.0110.00315.07
8.0.70.0050.00315.05
8.0.60.0050.00415.11
8.0.50.0010.00615.07
8.0.30.0060.00915.79
8.0.20.0120.00816.06
8.0.10.0030.00515.18
8.0.00.0110.00415.64
7.4.330.0060.00015.00
7.4.320.0060.00016.64
7.4.300.0070.00016.59
7.4.290.0000.00816.54
7.4.280.0000.00716.43
7.4.270.0030.00316.64
7.4.260.0000.00716.42
7.4.250.0050.00314.90
7.4.240.0030.00415.53
7.4.230.0050.00114.83
7.4.220.0030.01215.02
7.4.210.0060.00815.84
7.4.200.0000.00614.93
7.4.190.0040.00314.86
7.4.180.0050.00013.35
7.4.160.0080.00515.02
7.4.150.0050.00715.41
7.4.140.0070.00816.29
7.4.130.0060.00815.47
7.4.120.0110.00415.54
7.4.110.0120.00414.77
7.4.100.0030.01515.03
7.4.90.0060.01014.81
7.4.80.0130.00216.31
7.4.70.0100.00714.88
7.4.60.0080.00614.82
7.4.50.0070.00214.83
7.4.40.0060.00517.95
7.4.30.0090.00414.85
7.4.20.0040.00413.10
7.4.10.0070.00013.40
7.4.00.0020.00914.17
7.3.330.0000.00613.22
7.3.320.0000.00613.37
7.3.310.0040.00414.94
7.3.300.0050.00214.90
7.3.290.0050.00614.75
7.3.280.0080.00815.68
7.3.270.0090.00515.32
7.3.260.0060.00814.92
7.3.250.0080.00715.44
7.3.240.0030.00914.86
7.3.230.0050.00814.93
7.3.220.0060.00313.10
7.3.210.0050.00914.95
7.3.200.0100.00716.33
7.3.190.0110.00414.89
7.3.180.0110.00214.79
7.3.170.0090.00414.83
7.3.160.0080.00514.85
7.3.150.0060.00213.32
7.3.140.0050.00313.16
7.3.130.0000.00613.27
7.3.120.0050.00513.97
7.3.110.0020.00513.25
7.3.100.0080.00213.27
7.3.90.0040.00413.52
7.3.80.0030.00513.34
7.3.70.0040.00413.27
7.3.60.0070.00013.47
7.3.50.0020.00413.38
7.3.40.0070.00013.33
7.3.30.0040.00413.47
7.3.20.0000.00715.30
7.3.10.0040.00415.19
7.3.00.0030.00615.00
7.2.340.0090.00413.42
7.2.330.0090.00615.15
7.2.320.0060.01015.19
7.2.310.0050.01015.08
7.2.300.0120.00315.09
7.2.290.0110.00815.11
7.2.280.0080.00413.41
7.2.270.0090.00413.49
7.2.260.0050.00913.39
7.2.250.0070.00713.31
7.2.240.0100.00313.47
7.2.230.0130.00013.32
7.2.220.0090.00313.31
7.2.210.0090.00313.32
7.2.200.0110.00413.61
7.2.190.0110.00313.58
7.2.180.0130.00013.57
7.2.170.0130.00013.61
7.2.160.0110.00213.50
7.2.150.0120.00415.43
7.2.140.0140.00015.45
7.2.130.0050.00915.54
7.2.120.0130.00015.26
7.2.110.0100.00315.53
7.2.100.0070.00515.43
7.2.90.0080.00515.32
7.2.80.0070.00615.29
7.2.70.0070.00615.43
7.2.60.0120.00116.12
7.2.50.0140.00015.32
7.2.40.0140.00015.43
7.2.30.0110.00315.32
7.2.20.0070.00715.52
7.2.10.0100.00315.45
7.2.00.0090.00315.37
7.1.330.0040.00814.33
7.1.320.0120.00014.27
7.1.310.0130.00014.46
7.1.300.0130.00014.29
7.1.290.0110.00314.33
7.1.280.0080.00414.24
7.1.270.0090.00314.20
7.1.260.0060.00614.31
7.1.250.0090.00314.15
7.1.240.0060.00614.29
7.1.230.0130.00014.22
7.1.220.0120.00014.35
7.1.210.0110.00014.26
7.1.200.0060.00715.08
7.1.190.0100.00314.42
7.1.180.0040.00814.45
7.1.170.0040.00814.21
7.1.160.0000.01314.27
7.1.150.0000.01214.37
7.1.140.0130.00014.15
7.1.130.0150.00014.18
7.1.120.0120.00014.30
7.1.110.0070.00714.35
7.1.100.0120.00014.42
7.1.90.0130.00014.31
7.1.80.0060.00614.14
7.1.70.0040.00515.68
7.1.60.0110.00717.02
7.1.50.0050.01315.69
7.1.40.0100.00314.36
7.1.30.0130.00014.26
7.1.20.0100.00414.37
7.1.10.0060.00614.16
7.1.00.0050.04018.25
7.0.330.0070.00414.25
7.0.320.0120.00014.21
7.0.310.0060.00614.20
7.0.300.0080.00514.02
7.0.290.0080.00414.21
7.0.280.0000.01114.27
7.0.270.0060.00614.09
7.0.260.0120.00014.25
7.0.250.0060.00614.39
7.0.240.0080.00414.16
7.0.230.0060.00614.39
7.0.220.0050.00714.13
7.0.210.0100.00214.23
7.0.200.0110.00315.42
7.0.190.0040.00814.25
7.0.180.0100.00314.30
7.0.170.0120.00014.33
7.0.160.0080.00414.30
7.0.150.0090.00314.10
7.0.140.0040.03718.05
7.0.130.0060.00614.24
7.0.120.0110.00314.14
7.0.110.0100.00314.07
7.0.100.0040.03417.18
7.0.90.0090.04217.10
7.0.80.0070.02517.12
7.0.70.0030.03317.17
7.0.60.0080.02617.14
7.0.50.0100.04717.27
7.0.40.0090.02517.13
7.0.30.0080.04517.16
7.0.20.0050.03917.10
7.0.10.0040.04117.21
7.0.00.0060.04517.14
5.6.400.0070.00412.52
5.6.390.0080.00412.75
5.6.380.0070.00412.64
5.6.370.0060.00612.82
5.6.360.0120.00012.64
5.6.350.0130.00012.90
5.6.340.0080.00412.76
5.6.330.0040.00712.57
5.6.320.0120.00012.64
5.6.310.0000.01312.76
5.6.300.0000.01112.63
5.6.290.0120.00012.67
5.6.280.0090.03517.05
5.6.270.0040.00912.80
5.6.260.0110.00312.77
5.6.250.0100.04116.72
5.6.240.0050.04116.74
5.6.230.0060.04516.60
5.6.220.0080.04016.89
5.6.210.0090.04216.70
5.6.200.0060.03817.06
5.6.190.0160.03817.14
5.6.180.0080.04117.01
5.6.170.0110.03717.06
5.6.160.0130.03717.08
5.6.150.0110.03816.99
5.6.140.0050.04017.00
5.6.130.0020.04717.10
5.6.120.0120.03717.06
5.6.110.0090.04316.94
5.6.100.0110.04416.88
5.6.90.0090.04316.85
5.6.80.0110.02816.69
5.6.70.0110.04016.69
5.6.60.0110.03516.79
5.6.50.0090.03716.67
5.6.40.0090.04116.74
5.6.30.0070.04216.73
5.6.20.0100.03916.62
5.6.10.0150.03516.59
5.6.00.0040.04316.66
5.5.380.0080.02716.67
5.5.370.0070.04016.79
5.5.360.0090.04216.57
5.5.350.0040.04516.62
5.5.340.0060.02616.78
5.5.330.0130.04016.88
5.5.320.0090.04216.78
5.5.310.0110.04016.71
5.5.300.0090.02516.76
5.5.290.0080.04116.76
5.5.280.0070.04616.87
5.5.270.0090.03916.84
5.5.260.0090.03516.91
5.5.250.0070.04216.78
5.5.240.0070.03716.59
5.5.230.0090.04216.53
5.5.220.0090.03916.57
5.5.210.0020.04316.60
5.5.200.0050.03316.44
5.5.190.0070.04216.49
5.5.180.0090.04016.46
5.5.170.0120.00012.55
5.5.160.0090.02016.47
5.5.150.0070.04516.44
5.5.140.0050.03316.33
5.5.130.0100.03716.39
5.5.120.0050.02716.29
5.5.110.0050.02616.29
5.5.100.0090.02216.41
5.5.90.0060.02516.47
5.5.80.0110.03616.54
5.5.70.0140.03716.39
5.5.60.0080.03516.43
5.5.50.0120.03716.46
5.5.40.0070.04016.41
5.5.30.0110.04316.50
5.5.20.0160.03516.45
5.5.10.0130.03716.42
5.5.00.0050.04216.50
5.4.450.0180.02816.14
5.4.440.0050.04216.13
5.4.430.0080.04016.20
5.4.420.0130.03516.15
5.4.410.0050.04216.00
5.4.400.0080.03615.96
5.4.390.0070.03915.86
5.4.380.0050.04515.99
5.4.370.0080.03315.85
5.4.360.0060.04215.82
5.4.350.0100.03015.76
5.4.340.0090.03715.84
5.4.330.0090.00212.73
5.4.320.0090.02715.88
5.4.310.0130.03215.85
5.4.300.0050.03815.94
5.4.290.0050.03715.90
5.4.280.0110.03515.91
5.4.270.0060.03115.99
5.4.260.0060.02415.92
5.4.250.0070.03215.95
5.4.240.0090.03815.88
5.4.230.0090.03915.80
5.4.220.0050.04415.86
5.4.210.0150.03215.81
5.4.200.0090.03615.71
5.4.190.0090.03715.86
5.4.180.0130.03615.71
5.4.170.0060.04115.99
5.4.160.0040.03315.76
5.4.150.0090.03915.81
5.4.140.0060.03814.63
5.4.130.0080.02014.62
5.4.120.0070.02014.68
5.4.110.0140.03114.66
5.4.100.0070.01814.62
5.4.90.0110.01514.61
5.4.80.0040.02014.70
5.4.70.0030.02414.62
5.4.60.0090.01614.53
5.4.50.0070.02014.63
5.4.40.0100.01714.58
5.4.30.0070.01814.49
5.4.20.0040.02014.62
5.4.10.0060.01814.56
5.4.00.0070.02214.21
5.3.290.0110.03413.86
5.3.280.0110.03013.80
5.3.270.0050.04413.96
5.3.260.0110.03413.78
5.3.250.0080.03813.77
5.3.240.0110.03813.74
5.3.230.0030.02513.86
5.3.220.0080.03613.82
5.3.210.0040.03813.86
5.3.200.0060.02013.80
5.3.190.0110.02713.73
5.3.180.0090.01713.86
5.3.170.0050.02213.90
5.3.160.0020.02813.83
5.3.150.0050.02513.77
5.3.140.0040.02113.76
5.3.130.0060.02213.69
5.3.120.0060.02013.81
5.3.110.0050.02313.81
5.3.100.0030.02213.55
5.3.90.0030.02213.64
5.3.80.0070.01813.39
5.3.70.0050.02413.39
5.3.60.0060.01813.60
5.3.50.0050.02113.45
5.3.40.0050.03113.41
5.3.30.0070.02413.56
5.3.20.0070.01613.41
5.3.10.0050.02613.31
5.3.00.0030.02313.19
5.2.170.0040.01911.49
5.2.160.0040.02411.45
5.2.150.0030.02311.46
5.2.140.0040.03211.47
5.2.130.0040.01511.38
5.2.120.0090.02511.41
5.2.110.0020.02811.47
5.2.100.0050.01711.39
5.2.90.0030.01811.47
5.2.80.0050.02011.49
5.2.70.0050.01811.25
5.2.60.0050.01511.34
5.2.50.0010.01811.33
5.2.40.0050.01511.42
5.2.30.0020.01811.44
5.2.20.0020.01611.13
5.2.10.0050.01611.15
5.2.00.0050.01511.10
5.1.60.0020.02410.33
5.1.50.0050.01610.49
5.1.40.0050.01310.38
5.1.30.0040.01310.70
5.1.20.0050.01410.67
5.1.10.0060.01110.40
5.1.00.0050.01310.31
5.0.50.0030.0109.52
5.0.40.0020.0139.48
5.0.30.0020.0169.40
5.0.20.0020.0129.39
5.0.10.0030.0129.38
5.0.00.0020.0179.38
4.4.90.0000.0109.38
4.4.80.0040.0079.38
4.4.70.0020.0089.38
4.4.60.0020.0089.38
4.4.50.0040.0079.38
4.4.40.0000.0279.38
4.4.30.0040.0089.38
4.4.20.0020.0089.38
4.4.10.0020.0089.38
4.4.00.0020.0139.38
4.3.110.0000.0139.38
4.3.100.0020.0079.38
4.3.90.0020.0089.38
4.3.80.0020.0129.38
4.3.70.0000.0109.38
4.3.60.0030.0079.38
4.3.50.0020.0089.38
4.3.40.0030.0119.38
4.3.30.0030.0079.38
4.3.20.0020.0089.38
4.3.10.0000.0109.38
4.3.00.0000.0089.38

preferences:
48.57 ms | 400 KiB | 5 Q