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) -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.60.0070.00716.75
8.3.50.0160.00521.91
8.3.40.0060.00918.79
8.3.30.0110.00419.23
8.3.20.0050.00320.26
8.3.10.0050.00323.65
8.3.00.0080.00019.38
8.2.180.0090.00616.48
8.2.170.0090.00922.96
8.2.160.0000.01420.43
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0040.01126.16
8.2.120.0040.00422.25
8.2.110.0040.00422.36
8.2.100.0070.00418.03
8.2.90.0040.00419.17
8.2.80.0080.00017.97
8.2.70.0000.00917.75
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0080.00020.07
8.2.30.0070.00018.26
8.2.20.0040.00417.77
8.2.10.0060.00318.16
8.2.00.0000.00717.81
8.1.280.0100.00725.92
8.1.270.0060.00323.82
8.1.260.0030.00526.35
8.1.250.0060.00328.09
8.1.240.0090.00923.81
8.1.230.0110.00019.01
8.1.220.0000.00917.79
8.1.210.0050.00518.77
8.1.200.0060.00317.22
8.1.190.0000.00817.25
8.1.180.0050.00518.10
8.1.170.0040.00418.64
8.1.160.0040.00421.96
8.1.150.0040.00418.57
8.1.140.0000.00717.35
8.1.130.0000.00817.84
8.1.120.0040.00417.35
8.1.110.0030.00517.38
8.1.100.0000.00717.38
8.1.90.0000.00717.36
8.1.80.0000.00717.48
8.1.70.0000.00717.31
8.1.60.0030.00617.53
8.1.50.0000.00817.52
8.1.40.0050.00317.43
8.1.30.0000.00817.59
8.1.20.0050.00317.65
8.1.10.0080.00017.50
8.1.00.0040.00417.55
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0030.00318.52
8.0.270.0050.00217.28
8.0.260.0070.00017.20
8.0.250.0050.00216.89
8.0.240.0030.00516.97
8.0.230.0030.00316.88
8.0.220.0000.00816.80
8.0.210.0000.00716.95
8.0.200.0060.00617.02
8.0.190.0000.00816.98
8.0.180.0000.00816.83
8.0.170.0080.00016.98
8.0.160.0020.00516.96
8.0.150.0030.00316.77
8.0.140.0040.00416.91
8.0.130.0030.00313.30
8.0.120.0000.00815.10
8.0.110.0040.00415.10
8.0.100.0070.00215.11
8.0.90.0070.00115.10
8.0.80.0050.00815.15
8.0.70.0060.00315.15
8.0.60.0020.00615.03
8.0.50.0020.00515.12
8.0.30.0070.00915.75
8.0.20.0070.00816.04
8.0.10.0080.00115.29
8.0.00.0080.00715.60
7.4.330.0050.00215.00
7.4.320.0040.00416.67
7.4.300.0030.00316.63
7.4.290.0040.00416.51
7.4.280.0070.00016.52
7.4.270.0000.00816.52
7.4.260.0000.00916.56
7.4.250.0050.00314.89
7.4.240.0060.00215.51
7.4.230.0050.00414.86
7.4.220.0070.00715.05
7.4.210.0070.00915.77
7.4.200.0050.00314.92
7.4.190.0030.00515.06
7.4.180.0020.00513.42
7.4.160.0080.00315.08
7.4.150.0060.00615.33
7.4.140.0030.01016.32
7.4.130.0090.00615.40
7.4.120.0110.00415.45
7.4.110.0120.00314.88
7.4.100.0070.00715.00
7.4.90.0070.00714.99
7.4.80.0080.00816.26
7.4.70.0090.00614.90
7.4.60.0080.00614.73
7.4.50.0070.00214.92
7.4.40.0050.00814.82
7.4.30.0100.00314.97
7.4.20.0070.00313.17
7.4.10.0060.00613.34
7.4.00.0040.01014.25
7.3.330.0060.00013.17
7.3.320.0000.00613.30
7.3.310.0100.00014.82
7.3.300.0060.00214.76
7.3.290.0040.00814.80
7.3.280.0080.01015.59
7.3.270.0040.00915.42
7.3.260.0080.00715.03
7.3.250.0110.00415.42
7.3.240.0060.01014.84
7.3.230.0090.00514.95
7.3.220.0070.00213.27
7.3.210.0050.00814.87
7.3.200.0120.00416.26
7.3.190.0070.00814.83
7.3.180.0060.00914.75
7.3.170.0070.00714.76
7.3.160.0050.00714.84
7.3.150.0000.00713.26
7.3.140.0030.00313.18
7.3.130.0000.00613.23
7.3.120.0070.00413.86
7.3.110.0000.00613.07
7.3.100.0050.00313.18
7.3.90.0050.00213.59
7.3.80.0000.00713.33
7.3.70.0000.00613.32
7.3.60.0060.00013.49
7.3.50.0030.00313.53
7.3.40.0020.00413.51
7.3.30.0030.00313.33
7.3.20.0060.00015.37
7.3.10.0040.00415.85
7.3.00.0040.00415.88
7.2.340.0060.00613.46
7.2.330.0110.00415.00
7.2.320.0110.00314.91
7.2.310.0070.00715.14
7.2.300.0120.00315.17
7.2.290.0100.00515.12
7.2.280.0080.00413.48
7.2.270.0080.00413.46
7.2.260.0100.00313.45
7.2.250.0100.00213.50
7.2.240.0040.00813.48
7.2.230.0090.00413.27
7.2.220.0120.00013.53
7.2.210.0120.00013.43
7.2.200.0110.00313.67
7.2.190.0070.00713.61
7.2.180.0080.00513.52
7.2.170.0080.00413.68
7.2.160.0080.00513.52
7.2.150.0100.00315.27
7.2.140.0120.00015.45
7.2.130.0110.00116.08
7.2.120.0080.00216.15
7.2.110.0060.00516.21
7.2.100.0030.01016.06
7.2.90.0060.00616.09
7.2.80.0080.00516.31
7.2.70.0060.00816.22
7.2.60.0060.00716.45
7.2.50.0050.00816.10
7.2.40.0060.00616.28
7.2.30.0070.00716.15
7.2.20.0060.00616.16
7.2.10.0060.00616.19
7.2.00.0070.00817.21
7.1.330.0120.00014.43
7.1.320.0060.00614.33
7.1.310.0080.00314.26
7.1.300.0080.00414.29
7.1.290.0050.00714.47
7.1.280.0080.00414.33
7.1.270.0030.00914.42
7.1.260.0080.00414.35
7.1.250.0060.00415.04
7.1.240.0070.00414.20
7.1.230.0060.00614.40
7.1.220.0080.00414.18
7.1.210.0130.00014.20
7.1.200.0080.00515.11
7.1.190.0090.00314.39
7.1.180.0120.00014.25
7.1.170.0130.00014.11
7.1.160.0060.00614.30
7.1.150.0090.00314.32
7.1.140.0090.00314.29
7.1.130.0090.00214.28
7.1.120.0130.00014.16
7.1.110.0100.00314.17
7.1.100.0070.00516.15
7.1.90.0110.00214.20
7.1.80.0070.00514.23
7.1.70.0070.00615.72
7.1.60.0060.01216.83
7.1.50.0090.00615.68
7.1.40.0100.00314.37
7.1.30.0060.00614.18
7.1.20.0060.00614.34
7.1.10.0120.00014.12
7.1.00.0080.03818.32
7.0.330.0110.00014.27
7.0.320.0060.00614.20
7.0.310.0100.00214.16
7.0.300.0080.00414.20
7.0.290.0080.00414.25
7.0.280.0120.00014.25
7.0.270.0120.00014.10
7.0.260.0120.00014.20
7.0.250.0120.00014.27
7.0.240.0060.00614.37
7.0.230.0080.00414.24
7.0.220.0120.00014.33
7.0.210.0060.00614.13
7.0.200.0180.00314.63
7.0.190.0120.00014.13
7.0.180.0120.00014.35
7.0.170.0060.00614.20
7.0.160.0100.00214.13
7.0.150.0120.00014.26
7.0.140.0050.04018.10
7.0.130.0030.00814.35
7.0.120.0110.00014.32
7.0.110.0120.00014.26
7.0.100.0110.00014.27
7.0.90.0120.00014.27
7.0.80.0120.00014.02
7.0.70.0060.02317.84
7.0.60.0060.02118.03
7.0.50.0030.02118.14
7.0.40.0040.02517.25
7.0.30.0060.01817.22
7.0.20.0040.01917.15
7.0.10.0070.01517.18
7.0.00.0070.02217.19
5.6.400.0070.00412.58
5.6.390.0070.00512.68
5.6.380.0060.00612.69
5.6.370.0110.00012.49
5.6.360.0090.00312.71
5.6.350.0110.00012.61
5.6.340.0070.00412.73
5.6.330.0080.00412.70
5.6.320.0090.00212.52
5.6.310.0110.00012.86
5.6.300.0030.00812.61
5.6.290.0110.00012.57
5.6.280.0040.03816.86
5.6.270.0070.00412.72
5.6.260.0110.00012.72
5.6.250.0040.00712.53
5.6.240.0090.00312.74
5.6.230.0090.00312.63
5.6.220.0080.02716.75
5.6.210.0070.02016.75
5.6.200.0060.01817.10
5.6.190.0090.01516.90
5.6.180.0050.01817.11
5.6.170.0030.02017.04
5.6.160.0050.01716.86
5.6.150.0050.01717.01
5.6.140.0030.02117.00
5.6.130.0050.01916.99
5.6.120.0030.02116.91
5.6.110.0050.01917.00
5.6.100.0060.02017.08
5.6.90.0080.01716.88
5.6.80.0040.02316.63
5.6.70.0040.04316.54
5.6.60.0050.02816.68
5.6.50.0090.04016.66
5.6.40.0090.04216.61
5.6.30.0090.03816.49
5.6.20.0120.02816.66
5.6.10.0040.04116.53
5.6.00.0050.04216.61
5.5.380.0080.00312.95
5.5.370.0110.00012.87
5.5.360.0060.02316.65
5.5.350.0030.01916.53
5.5.340.0060.02016.69
5.5.330.0050.02516.79
5.5.320.0030.02016.91
5.5.310.0040.01916.91
5.5.300.0040.01816.78
5.5.290.0050.01816.77
5.5.280.0040.02016.76
5.5.270.0060.01816.80
5.5.260.0090.02016.76
5.5.250.0080.01516.72
5.5.240.0050.02516.50
5.5.230.0100.03916.60
5.5.220.0040.04316.58
5.5.210.0090.04016.60
5.5.200.0050.03016.37
5.5.190.0100.03816.32
5.5.180.0060.04216.43
5.5.170.0090.00212.64
5.5.160.0070.03216.46
5.5.150.0080.03216.40
5.5.140.0080.04116.35
5.5.130.0080.03816.27
5.5.120.0080.03816.40
5.5.110.0040.04416.39
5.5.100.0040.03416.28
5.5.90.0070.02016.52
5.5.80.0080.03616.48
5.5.70.0040.04016.53
5.5.60.0050.03016.47
5.5.50.0140.03516.32
5.5.40.0090.03716.38
5.5.30.0070.03016.37
5.5.20.0060.04116.45
5.5.10.0050.03316.39
5.5.00.0090.03816.40
5.4.450.0040.01816.07
5.4.440.0040.01816.06
5.4.430.0040.01816.10
5.4.420.0050.02216.13
5.4.410.0040.02316.10
5.4.400.0050.03915.86
5.4.390.0070.02315.86
5.4.380.0060.03815.81
5.4.370.0080.03815.80
5.4.360.0110.03315.74
5.4.350.0040.04016.00
5.4.340.0070.03415.94
5.4.330.0080.00412.73
5.4.320.0060.04215.82
5.4.310.0060.03115.72
5.4.300.0070.03815.86
5.4.290.0070.03515.92
5.4.280.0050.03215.82
5.4.270.0120.03315.96
5.4.260.0060.03815.96
5.4.250.0020.02415.76
5.4.240.0050.03715.79
5.4.230.0070.04015.70
5.4.220.0140.03315.80
5.4.210.0060.03915.59
5.4.200.0020.04415.80
5.4.190.0050.04115.92
5.4.180.0080.03715.74
5.4.170.0080.03515.86
5.4.160.0050.03815.89
5.4.150.0090.03615.63
5.4.140.0040.04314.40
5.4.130.0060.03814.67
5.4.120.0070.03214.50
5.4.110.0030.04014.71
5.4.100.0060.03914.53
5.4.90.0050.03614.64
5.4.80.0040.03714.58
5.4.70.0040.03814.52
5.4.60.0090.03314.69
5.4.50.0110.03214.56
5.4.40.0030.04214.67
5.4.30.0090.03314.62
5.4.20.0050.04014.66
5.4.10.0030.03614.53
5.4.00.0000.04214.22
5.3.290.0060.03813.85
5.3.280.0080.02913.77
5.3.270.0060.03113.82
5.3.260.0060.04113.76
5.3.250.0040.04013.92
5.3.240.0050.03713.71
5.3.230.0090.03713.90
5.3.220.0050.03313.75
5.3.210.0080.03313.72
5.3.200.0100.03513.83
5.3.190.0090.03713.84
5.3.180.0040.03813.90
5.3.170.0070.03713.81
5.3.160.0050.03713.82
5.3.150.0060.04013.84
5.3.140.0040.03513.76
5.3.130.0080.03813.84
5.3.120.0040.04113.83
5.3.110.0060.04013.85
5.3.100.0030.04113.54
5.3.90.0090.02713.68
5.3.80.0030.03713.42
5.3.70.0070.03813.47
5.3.60.0040.03413.55
5.3.50.0070.03713.47
5.3.40.0090.02613.41
5.3.30.0030.04013.52
5.3.20.0060.03613.48
5.3.10.0070.03213.21
5.3.00.0020.04013.33
5.2.170.0040.02611.51
5.2.160.0020.03211.64
5.2.150.0030.03311.46
5.2.140.0020.03211.49
5.2.130.0050.02011.61
5.2.120.0040.02711.50
5.2.110.0040.02411.49
5.2.100.0060.02711.62
5.2.90.0030.02611.63
5.2.80.0000.03011.59
5.2.70.0060.03011.46
5.2.60.0030.03411.47
5.2.50.0060.03211.48
5.2.40.0060.03011.47
5.2.30.0060.02811.59
5.2.20.0080.02811.52
5.2.10.0060.02811.38
5.2.00.0040.03111.33
5.1.60.0000.03110.97
5.1.50.0030.02511.14
5.1.40.0090.02011.22
5.1.30.0020.02211.10
5.1.20.0040.01811.04
5.1.10.0030.02311.02
5.1.00.0020.01910.96
5.0.50.0020.01310.94
5.0.40.0050.02010.94
5.0.30.0030.03510.94
5.0.20.0020.02010.94
5.0.10.0050.01510.94
5.0.00.0030.02610.94
4.4.90.0000.01710.94
4.4.80.0040.01710.94
4.4.70.0000.02010.94
4.4.60.0020.01710.94
4.4.50.0050.01510.94
4.4.40.0040.02210.94
4.4.30.0020.01710.94
4.4.20.0020.00810.94
4.4.10.0000.02210.94
4.4.00.0020.02710.94
4.3.110.0030.01310.94
4.3.100.0020.01510.94
4.3.90.0020.01810.94
4.3.80.0010.02810.94
4.3.70.0010.01610.94
4.3.60.0020.01710.94
4.3.50.0020.01810.94
4.3.40.0040.01810.94
4.3.30.0000.01510.94
4.3.20.0050.01510.94
4.3.10.0020.01510.94
4.3.00.0020.01610.94

preferences:
48.05 ms | 400 KiB | 5 Q