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); var_dump($path_components); var_dump($rel_components); for($i = 0 ; $i < count($rel_components) ; ++$i) { if ($path_components[$i] == $rel[$i]) array_shift($copy); else break; } var_dump($copy); 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.0110.00718.05
8.3.50.0080.01022.01
8.3.40.0070.00718.82
8.3.30.0110.00319.18
8.3.20.0040.00420.21
8.3.10.0040.00422.14
8.3.00.0000.00822.46
8.2.180.0040.01118.41
8.2.170.0110.01122.96
8.2.160.0000.01421.02
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0040.00417.63
8.2.110.0090.00022.05
8.2.100.0090.00317.72
8.2.90.0000.00819.06
8.2.80.0000.00818.05
8.2.70.0000.00817.75
8.2.60.0050.00317.93
8.2.50.0040.00418.07
8.2.40.0070.00418.22
8.2.30.0080.00018.20
8.2.20.0040.00417.86
8.2.10.0050.00317.78
8.2.00.0030.00617.70
8.1.280.0150.00325.92
8.1.270.0040.00423.76
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0050.00524.01
8.1.230.0040.00818.97
8.1.220.0040.00417.76
8.1.210.0060.00318.77
8.1.200.0030.00617.35
8.1.190.0080.00017.43
8.1.180.0080.00018.10
8.1.170.0030.00618.70
8.1.160.0050.00222.05
8.1.150.0040.00418.65
8.1.140.0040.00417.52
8.1.130.0030.00317.77
8.1.120.0070.00017.45
8.1.110.0030.00517.52
8.1.100.0040.00417.38
8.1.90.0000.00817.39
8.1.80.0030.00417.39
8.1.70.0070.00017.47
8.1.60.0000.00817.63
8.1.50.0030.00617.53
8.1.40.0040.00417.43
8.1.30.0050.00517.67
8.1.20.0040.00417.67
8.1.10.0000.00717.49
8.1.00.0040.00417.58
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0030.00318.52
8.0.270.0070.00017.29
8.0.260.0030.00316.75
8.0.250.0000.00717.00
8.0.240.0040.00417.00
8.0.230.0090.00016.96
8.0.220.0000.00716.93
8.0.210.0030.00316.95
8.0.200.0000.00716.99
8.0.190.0040.00416.87
8.0.180.0000.00716.86
8.0.170.0040.00416.92
8.0.160.0040.00416.89
8.0.150.0040.00316.83
8.0.140.0040.00416.83
8.0.130.0000.00513.42
8.0.120.0080.00315.13
8.0.110.0070.00415.06
8.0.100.0060.00415.10
8.0.90.0020.00915.01
8.0.80.0060.00815.13
8.0.70.0060.00515.10
8.0.60.0090.00015.04
8.0.50.0100.00115.07
8.0.30.0060.01115.96
8.0.20.0080.00816.03
8.0.10.0030.00715.28
8.0.00.0070.01015.68
7.4.330.0020.00215.00
7.4.320.0060.00016.67
7.4.300.0000.00616.54
7.4.290.0070.00016.59
7.4.280.0000.00716.41
7.4.270.0080.00016.54
7.4.260.0070.00016.60
7.4.250.0040.00414.92
7.4.240.0050.00415.39
7.4.230.0090.00214.87
7.4.220.0090.00615.02
7.4.210.0110.00515.81
7.4.200.0040.00614.89
7.4.190.0040.00615.00
7.4.180.0050.00213.42
7.4.160.0060.00615.02
7.4.150.0060.00715.34
7.4.140.0100.00516.36
7.4.130.0080.00915.40
7.4.120.0120.00615.43
7.4.110.0060.00914.83
7.4.100.0080.00714.87
7.4.90.0100.00414.96
7.4.80.0050.01014.82
7.4.70.0070.00614.84
7.4.60.0120.00414.88
7.4.50.0090.00114.90
7.4.40.0110.00517.94
7.4.30.0080.01014.83
7.4.20.0110.00313.14
7.4.10.0090.00413.28
7.4.00.0060.00914.24
7.3.330.0000.00613.39
7.3.320.0050.00013.37
7.3.310.0060.00514.81
7.3.300.0100.00014.81
7.3.290.0080.00614.80
7.3.280.0120.00515.60
7.3.270.0090.00715.38
7.3.260.0090.00714.83
7.3.250.0080.00915.40
7.3.240.0100.00714.91
7.3.230.0090.00715.00
7.3.220.0070.00513.13
7.3.210.0090.00714.72
7.3.200.0150.00416.30
7.3.190.0100.00814.79
7.3.180.0110.00515.00
7.3.170.0120.00614.87
7.3.160.0080.00614.82
7.3.150.0000.00813.07
7.3.140.0070.00213.27
7.3.130.0030.00313.34
7.3.120.0090.00314.10
7.3.110.0040.00213.10
7.3.100.0120.00013.23
7.3.90.0000.00713.55
7.3.80.0040.00413.27
7.3.70.0070.00013.46
7.3.60.0040.00213.57
7.3.50.0030.00313.48
7.3.40.0000.00613.42
7.3.30.0070.00013.51
7.3.20.0040.00215.13
7.3.10.0000.00715.02
7.3.00.0050.00515.29
7.2.340.0090.00513.27
7.2.330.0100.00815.02
7.2.320.0090.00814.96
7.2.310.0130.00615.08
7.2.300.0100.00615.12
7.2.290.0130.00614.99
7.2.280.0100.00313.42
7.2.270.0090.00613.35
7.2.260.0030.01013.51
7.2.250.0100.00313.32
7.2.240.0090.00413.49
7.2.230.0090.00413.54
7.2.220.0080.00413.52
7.2.210.0130.00013.34
7.2.200.0130.00013.64
7.2.190.0090.00613.63
7.2.180.0080.00413.63
7.2.170.0090.00613.58
7.2.160.0080.00413.69
7.2.150.0110.00415.36
7.2.140.0090.00415.47
7.2.130.0140.00015.34
7.2.120.0090.00615.98
7.2.110.0090.00516.09
7.2.100.0080.00415.94
7.2.90.0100.00216.06
7.2.80.0070.00516.14
7.2.70.0100.00416.08
7.2.60.0060.00716.42
7.2.50.0050.00716.17
7.2.40.0110.00416.14
7.2.30.0070.00616.21
7.2.20.0070.00916.13
7.2.10.0110.00516.27
7.2.00.0070.00516.20
7.1.330.0070.00714.41
7.1.320.0040.00914.41
7.1.310.0140.00014.20
7.1.300.0140.00014.35
7.1.290.0070.00714.26
7.1.280.0030.01014.21
7.1.270.0060.00614.26
7.1.260.0130.00014.30
7.1.250.0120.00014.25
7.1.240.0060.00615.01
7.1.230.0100.00315.03
7.1.220.0080.00515.02
7.1.210.0090.00414.89
7.1.200.0050.00815.42
7.1.190.0070.00715.06
7.1.180.0050.00715.00
7.1.170.0050.00915.03
7.1.160.0080.00514.98
7.1.150.0050.00814.95
7.1.140.0070.00715.08
7.1.130.0100.00415.00
7.1.120.0080.00614.95
7.1.110.0100.00515.04
7.1.100.0100.00514.91
7.1.90.0070.00614.97
7.1.80.0090.00214.98
7.1.70.0060.00615.75
7.1.60.0090.00816.65
7.1.50.0030.01215.81
7.1.40.0070.00715.10
7.1.30.0020.01215.15
7.1.20.0110.00315.09
7.1.10.0110.00215.06
7.1.00.0070.02617.43
7.0.330.0040.00814.17
7.0.320.0080.00514.75
7.0.310.0030.01014.93
7.0.300.0050.00714.63
7.0.290.0070.00614.80
7.0.280.0070.00414.83
7.0.270.0080.00414.85
7.0.260.0100.00414.79
7.0.250.0080.00314.90
7.0.240.0070.00415.00
7.0.230.0060.00814.97
7.0.220.0080.00514.65
7.0.210.0050.00614.98
7.0.200.0030.00915.54
7.0.190.0060.00414.86
7.0.180.0070.00514.83
7.0.170.0090.00314.88
7.0.160.0060.00614.68
7.0.150.0060.00814.67
7.0.140.0060.02717.27
7.0.130.0060.00714.86
7.0.120.0090.00214.93
7.0.110.0080.00514.89
7.0.100.0060.02016.53
7.0.90.0070.02916.54
7.0.80.0060.03016.63
7.0.70.0170.03116.50
7.0.60.0070.03016.56
7.0.50.0080.03016.62
7.0.40.0060.03215.91
7.0.30.0110.01615.92
7.0.20.0070.02815.91
7.0.10.0110.02716.01
7.0.00.0080.03215.97
5.6.400.0120.00012.56
5.6.390.0110.00012.95
5.6.380.0060.00513.67
5.6.370.0070.00713.60
5.6.360.0090.00513.64
5.6.350.0070.00713.44
5.6.340.0060.00613.74
5.6.330.0110.00313.74
5.6.320.0120.00213.48
5.6.310.0040.00913.82
5.6.300.0110.00313.80
5.6.290.0040.00613.61
5.6.280.0050.02815.91
5.6.270.0050.00913.58
5.6.260.0070.00513.67
5.6.250.0070.03115.81
5.6.240.0060.02016.00
5.6.230.0090.03016.05
5.6.220.0070.02715.90
5.6.210.0100.02115.96
5.6.200.0080.01816.10
5.6.190.0090.02116.16
5.6.180.0050.02116.11
5.6.170.0120.01816.01
5.6.160.0060.02116.09
5.6.150.0070.01716.15
5.6.140.0100.02716.04
5.6.130.0080.02716.29
5.6.120.0100.01816.09
5.6.110.0060.03116.10
5.6.100.0100.03016.16
5.6.90.0100.02915.97
5.6.80.0060.03215.84
5.6.70.0070.02115.89
5.6.60.0050.02315.93
5.6.50.0070.03015.79
5.6.40.0030.03115.81
5.6.30.0070.03115.85
5.6.20.0070.03215.81
5.6.10.0060.03115.84
5.6.00.0100.02715.83
5.5.380.0070.02914.99
5.5.370.0060.02814.87
5.5.360.0040.02014.82
5.5.350.0030.02214.83
5.5.340.0060.03114.99
5.5.330.0040.02014.94
5.5.320.0080.02514.88
5.5.310.0080.01615.01
5.5.300.0090.01615.06
5.5.290.0080.02714.93
5.5.280.0070.02414.94
5.5.270.0080.02914.95
5.5.260.0050.02214.90
5.5.250.0090.02814.87
5.5.240.0060.01714.87
5.5.230.0050.02814.76
5.5.220.0100.02014.78
5.5.210.0120.02214.89
5.5.200.0050.03114.78
5.5.190.0090.02914.66
5.5.180.0030.02514.80
5.5.170.0050.00813.39
5.5.160.0070.01614.75
5.5.150.0070.01514.75
5.5.140.0080.02714.68
5.5.130.0080.02814.64
5.5.120.0050.02114.72
5.5.110.0090.01714.71
5.5.100.0070.02814.77
5.5.90.0050.02814.77
5.5.80.0030.03014.68
5.5.70.0080.02714.79
5.5.60.0060.01614.66
5.5.50.0070.02814.71
5.5.40.0080.02414.76
5.5.30.0090.02814.73
5.5.20.0100.02314.67
5.5.10.0050.02414.72
5.5.00.0050.01714.64
5.4.450.0100.01614.52
5.4.440.0070.02914.51
5.4.430.0060.02614.41
5.4.420.0070.02314.50
5.4.410.0060.02814.48
5.4.400.0080.01514.35
5.4.390.0090.02814.44
5.4.380.0100.02514.29
5.4.370.0060.01714.40
5.4.360.0090.02714.31
5.4.350.0080.02714.25
5.4.340.0050.03014.44
5.4.330.0040.00412.00
5.4.320.0080.02514.31
5.4.310.0010.02014.32
5.4.300.0110.02614.25
5.4.290.0060.01814.48
5.4.280.0040.01714.43
5.4.270.0040.01514.33
5.4.260.0050.02914.27
5.4.250.0060.02614.33
5.4.240.0040.02414.30
5.4.230.0030.02614.25
5.4.220.0080.01914.38
5.4.210.0040.02914.27
5.4.200.0050.02614.37
5.4.190.0040.02914.22
5.4.180.0070.02714.33
5.4.170.0070.02414.29
5.4.160.0070.02914.30
5.4.150.0030.02914.25
5.4.140.0090.02513.46
5.4.130.0070.02813.54
5.4.120.0080.02713.50
5.4.110.0060.02513.49
5.4.100.0090.01613.58
5.4.90.0070.01813.47
5.4.80.0130.01413.56
5.4.70.0070.02613.60
5.4.60.0070.01413.54
5.4.50.0060.02613.39
5.4.40.0090.02113.45
5.4.30.0040.02213.56
5.4.20.0050.02813.56
5.4.10.0060.02713.52
5.4.00.0110.02013.18
5.3.290.0060.02813.01
5.3.280.0040.02012.92
5.3.270.0060.02112.92
5.3.260.0040.02912.95
5.3.250.0050.02113.02
5.3.240.0050.02312.87
5.3.230.0050.03012.98
5.3.220.0030.02512.98
5.3.210.0100.02912.84
5.3.200.0070.02712.94
5.3.190.0060.01913.02
5.3.180.0050.03212.96
5.3.170.0050.01813.07
5.3.160.0050.02813.09
5.3.150.0090.02212.94
5.3.140.0100.01613.01
5.3.130.0050.03012.98
5.3.120.0080.02512.91
5.3.110.0060.02812.90
5.3.100.0050.02812.75
5.3.90.0070.02512.77
5.3.80.0060.02612.74
5.3.70.0120.02212.72
5.3.60.0060.02812.83
5.3.50.0060.02812.77
5.3.40.0030.03212.69
5.3.30.0060.02612.79
5.3.20.0050.02612.70
5.3.10.0060.01712.66
5.3.00.0060.01312.58
5.2.170.0100.01511.72
5.2.160.0070.01711.73
5.2.150.0050.02211.71
5.2.140.0080.01311.79
5.2.130.0020.01511.79
5.2.120.0040.02211.71
5.2.110.0060.02111.69
5.2.100.0060.01811.79
5.2.90.0060.02211.72
5.2.80.0060.02111.77
5.2.70.0040.01811.72
5.2.60.0050.02311.67
5.2.50.0040.02411.71
5.2.40.0050.01411.72
5.2.30.0070.01111.70
5.2.20.0070.01911.71
5.2.10.0060.01211.65
5.2.00.0020.02611.67
5.1.60.0060.02011.40
5.1.50.0070.01511.40
5.1.40.0070.01511.53
5.1.30.0030.01711.45
5.1.20.0070.01211.43
5.1.10.0080.01211.40
5.1.00.0060.01711.44
5.0.50.0020.01311.34
5.0.40.0050.01411.34
5.0.30.0040.01311.34
5.0.20.0050.01211.34
5.0.10.0050.01511.34
5.0.00.0040.02411.34
4.4.90.0020.01311.34
4.4.80.0030.00711.34
4.4.70.0030.00611.34
4.4.60.0020.01111.34
4.4.50.0030.01311.34
4.4.40.0040.01211.34
4.4.30.0030.00711.34
4.4.20.0020.01411.34
4.4.10.0010.01311.34
4.4.00.0050.01811.34
4.3.110.0030.01411.34
4.3.100.0030.00911.34
4.3.90.0040.01211.34
4.3.80.0050.01511.34
4.3.70.0030.01111.34
4.3.60.0020.01011.34
4.3.50.0030.01411.34
4.3.40.0020.02011.34
4.3.30.0030.01111.34
4.3.20.0030.01211.34
4.3.10.0020.00811.34
4.3.00.0010.01311.34

preferences:
43.46 ms | 401 KiB | 5 Q