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]) $copy = 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.0030.01016.75
8.3.50.0090.01322.06
8.3.40.0080.00818.92
8.3.30.0080.00618.86
8.3.20.0000.00720.34
8.3.10.0040.00421.78
8.3.00.0040.00420.71
8.2.180.0140.00716.50
8.2.170.0170.00322.96
8.2.160.0130.00722.08
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00421.98
8.2.110.0000.00920.97
8.2.100.0130.00017.91
8.2.90.0030.00519.26
8.2.80.0080.00017.97
8.2.70.0000.00917.63
8.2.60.0000.00718.03
8.2.50.0000.00918.07
8.2.40.0000.00819.27
8.2.30.0030.00518.14
8.2.20.0040.00417.77
8.2.10.0040.00417.86
8.2.00.0040.00517.82
8.1.280.0070.00725.92
8.1.270.0080.00023.97
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0000.00921.43
8.1.230.0000.01119.61
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.00917.47
8.1.190.0060.00317.65
8.1.180.0040.00418.10
8.1.170.0000.00818.46
8.1.160.0000.00822.05
8.1.150.0080.00018.67
8.1.140.0000.00717.47
8.1.130.0000.00717.79
8.1.120.0040.00417.49
8.1.110.0050.00317.31
8.1.100.0040.00317.46
8.1.90.0000.00717.45
8.1.80.0070.00017.48
8.1.70.0000.00717.36
8.1.60.0040.00417.66
8.1.50.0000.00817.53
8.1.40.0040.00417.51
8.1.30.0040.00417.68
8.1.20.0040.00417.52
8.1.10.0050.00317.49
8.1.00.0040.00417.52
8.0.300.0000.00818.77
8.0.290.0000.00817.04
8.0.280.0000.00718.38
8.0.270.0030.00317.22
8.0.260.0030.00316.92
8.0.250.0000.00717.04
8.0.240.0040.00717.02
8.0.230.0030.00317.03
8.0.220.0000.00717.00
8.0.210.0030.00317.02
8.0.200.0030.00317.06
8.0.190.0000.00716.92
8.0.180.0040.00416.93
8.0.170.0000.00817.02
8.0.160.0000.00716.85
8.0.150.0070.00017.01
8.0.140.0040.00316.97
8.0.130.0000.00613.38
8.0.120.0020.00515.18
8.0.110.0030.00515.18
8.0.100.0030.00515.12
8.0.90.0040.00515.21
8.0.80.0030.01015.21
8.0.70.0020.00715.14
8.0.60.0050.00315.06
8.0.50.0030.00515.12
8.0.30.0090.00615.86
8.0.20.0080.00716.04
8.0.10.0040.00415.29
8.0.00.0050.01015.66
7.4.330.0000.00615.00
7.4.320.0000.00616.54
7.4.300.0030.00316.38
7.4.290.0070.00016.61
7.4.280.0000.00716.52
7.4.270.0000.00716.52
7.4.260.0000.00716.46
7.4.250.0040.00415.00
7.4.240.0040.00415.55
7.4.230.0040.00414.99
7.4.220.0130.00214.94
7.4.210.0100.00615.85
7.4.200.0060.00414.96
7.4.190.0050.00515.05
7.4.180.0050.00313.44
7.4.160.0060.00915.10
7.4.150.0050.00815.37
7.4.140.0080.00716.32
7.4.130.0060.01015.47
7.4.120.0060.00815.41
7.4.110.0070.00714.79
7.4.100.0080.00514.90
7.4.90.0080.00814.79
7.4.80.0090.00314.84
7.4.70.0090.00614.87
7.4.60.0110.00514.93
7.4.50.0080.00014.81
7.4.40.0050.00817.98
7.4.30.0110.00314.94
7.4.20.0000.00813.36
7.4.10.0070.00414.27
7.4.00.0090.00514.46
7.3.330.0030.00313.44
7.3.320.0030.00313.25
7.3.310.0000.00714.89
7.3.300.0010.00614.95
7.3.290.0070.00714.92
7.3.280.0080.00615.66
7.3.270.0060.00715.43
7.3.260.0060.00815.00
7.3.250.0100.00415.35
7.3.240.0030.00914.83
7.3.230.0110.00214.87
7.3.220.0080.00013.42
7.3.210.0060.00614.86
7.3.200.0100.00416.30
7.3.190.0050.01114.91
7.3.180.0030.00914.85
7.3.170.0080.00414.93
7.3.160.0070.00514.93
7.3.150.0000.00713.31
7.3.140.0060.00013.23
7.3.130.0010.00914.15
7.3.120.0090.00514.44
7.3.110.0050.00814.13
7.3.100.0040.00614.12
7.3.90.0000.01114.15
7.3.80.0100.00214.08
7.3.70.0030.00414.14
7.3.60.0040.00714.14
7.3.50.0060.00314.22
7.3.40.0080.00214.28
7.3.30.0040.00314.14
7.3.20.0080.00316.05
7.3.10.0050.00615.80
7.3.00.0060.00416.02
7.2.340.0120.00013.52
7.2.330.0110.00415.09
7.2.320.0100.00514.96
7.2.310.0040.01115.15
7.2.300.0100.00515.13
7.2.290.0100.00515.18
7.2.280.0080.00613.30
7.2.270.0130.00013.50
7.2.260.0070.01014.29
7.2.250.0110.00514.17
7.2.240.0070.00714.42
7.2.230.0060.00714.13
7.2.220.0000.01214.37
7.2.210.0120.00314.28
7.2.200.0040.01114.34
7.2.190.0110.00314.21
7.2.180.0070.00714.41
7.2.170.0110.00214.45
7.2.160.0090.00414.37
7.2.150.0080.00516.13
7.2.140.0020.01116.05
7.2.130.0060.00516.17
7.2.120.0060.00816.16
7.2.110.0090.00516.13
7.2.100.0120.00316.08
7.2.90.0070.00616.04
7.2.80.0070.00616.15
7.2.70.0050.01016.18
7.2.60.0130.00216.22
7.2.50.0060.00816.13
7.2.40.0130.00216.15
7.2.30.0090.00616.11
7.2.20.0100.00316.16
7.2.10.0080.00416.14
7.2.00.0040.01017.23
7.1.330.0110.00215.02
7.1.320.0090.00514.96
7.1.310.0040.00915.15
7.1.300.0080.00315.11
7.1.290.0080.00515.23
7.1.280.0110.00214.98
7.1.270.0050.00715.10
7.1.260.0100.00414.97
7.1.250.0080.00315.06
7.1.240.0050.00515.01
7.1.230.0060.00514.94
7.1.220.0090.00614.87
7.1.210.0080.00615.02
7.1.200.0110.00015.07
7.1.190.0070.00715.04
7.1.180.0110.00215.04
7.1.170.0000.01415.12
7.1.160.0080.00615.12
7.1.150.0080.00615.00
7.1.140.0040.00914.97
7.1.130.0040.00915.07
7.1.120.0050.00815.08
7.1.110.0080.00315.16
7.1.100.0060.00616.02
7.1.90.0080.00514.98
7.1.80.0080.00515.13
7.1.70.0060.00315.60
7.1.60.0080.00816.38
7.1.50.0070.00715.79
7.1.40.0060.00515.12
7.1.30.0060.00814.95
7.1.20.0020.01114.84
7.1.10.0070.00515.16
7.1.00.0070.02717.48
7.0.330.0050.00814.77
7.0.320.0070.00614.89
7.0.310.0050.00814.84
7.0.300.0050.00814.84
7.0.290.0060.00814.90
7.0.280.0070.00414.89
7.0.270.0060.00414.81
7.0.260.0040.00714.93
7.0.250.0030.00914.83
7.0.240.0080.00514.73
7.0.230.0070.00414.83
7.0.220.0060.00714.86
7.0.210.0050.00714.77
7.0.200.0060.00715.50
7.0.190.0040.00814.66
7.0.180.0080.00414.94
7.0.170.0080.00514.98
7.0.160.0040.00814.80
7.0.150.0060.00814.71
7.0.140.0070.02517.27
7.0.130.0060.00514.71
7.0.120.0100.00315.01
7.0.110.0060.00614.69
7.0.100.0080.02716.58
7.0.90.0070.02116.49
7.0.80.0080.03116.50
7.0.70.0130.02316.49
7.0.60.0030.02916.46
7.0.50.0080.02616.71
7.0.40.0080.02115.99
7.0.30.0070.03415.92
7.0.20.0050.02515.87
7.0.10.0060.02116.00
7.0.00.0080.02015.91
5.6.400.0090.00413.73
5.6.390.0060.00713.71
5.6.380.0060.00713.72
5.6.370.0050.00613.50
5.6.360.0110.00313.64
5.6.350.0060.00613.52
5.6.340.0070.00513.80
5.6.330.0060.00713.70
5.6.320.0030.00913.66
5.6.310.0080.00613.55
5.6.300.0050.00813.65
5.6.290.0080.00213.66
5.6.280.0050.02916.06
5.6.270.0080.00513.67
5.6.260.0040.01013.45
5.6.250.0040.03416.01
5.6.240.0080.01915.91
5.6.230.0050.03115.92
5.6.220.0050.02716.05
5.6.210.0070.02415.96
5.6.200.0070.02116.15
5.6.190.0080.03116.19
5.6.180.0040.02416.12
5.6.170.0100.02516.22
5.6.160.0090.02816.20
5.6.150.0110.02316.21
5.6.140.0040.02616.12
5.6.130.0100.02915.96
5.6.120.0080.03215.95
5.6.110.0090.02016.13
5.6.100.0090.02716.22
5.6.90.0060.03716.08
5.6.80.0080.02715.81
5.6.70.0080.01715.93
5.6.60.0060.02915.82
5.6.50.0060.01915.81
5.6.40.0070.01815.86
5.6.30.0110.02615.87
5.6.20.0070.03115.84
5.6.10.0100.01915.88
5.6.00.0030.02115.80
5.5.380.0090.02616.00
5.5.370.0080.02015.79
5.5.360.0050.01816.00
5.5.350.0110.02915.81
5.5.340.0060.02115.98
5.5.330.0110.02516.01
5.5.320.0110.02616.01
5.5.310.0040.02015.96
5.5.300.0070.02116.00
5.5.290.0090.02016.10
5.5.280.0090.01916.04
5.5.270.0070.03116.01
5.5.260.0100.01515.92
5.5.250.0060.02115.89
5.5.240.0060.03315.89
5.5.230.0080.02915.74
5.5.220.0100.02615.67
5.5.210.0050.02415.91
5.5.200.0080.02815.72
5.5.190.0070.03015.85
5.5.180.0080.02815.70
5.5.170.0090.00413.61
5.5.160.0070.02515.73
5.5.150.0060.03015.84
5.5.140.0080.01715.73
5.5.130.0060.03015.80
5.5.120.0060.03115.52
5.5.110.0080.02715.72
5.5.100.0040.03015.67
5.5.90.0050.02015.64
5.5.80.0080.02215.60
5.5.70.0060.03115.68
5.5.60.0070.02815.76
5.5.50.0070.01815.83
5.5.40.0060.02915.58
5.5.30.0070.02915.72
5.5.20.0080.02215.82
5.5.10.0100.01915.68
5.5.00.0090.02915.71
5.4.450.0060.02415.12
5.4.440.0070.02715.23
5.4.430.0060.02315.25
5.4.420.0070.02815.08
5.4.410.0040.02015.17
5.4.400.0080.03015.11
5.4.390.0070.02715.02
5.4.380.0070.02914.97
5.4.370.0070.02815.08
5.4.360.0080.02515.05
5.4.350.0080.03015.11
5.4.340.0080.02015.12
5.4.330.0060.00613.03
5.4.320.0060.02415.10
5.4.310.0070.02815.08
5.4.300.0090.02215.08
5.4.290.0100.02614.96
5.4.280.0060.01615.10
5.4.270.0040.01414.98
5.4.260.0070.02614.99
5.4.250.0050.02915.02
5.4.240.0040.01715.02
5.4.230.0080.03015.07
5.4.220.0070.02114.93
5.4.210.0040.02815.00
5.4.200.0070.02614.93
5.4.190.0030.03014.98
5.4.180.0090.02615.01
5.4.170.0060.02914.94
5.4.160.0070.01614.91
5.4.150.0050.02815.02
5.4.140.0070.01614.13
5.4.130.0060.01514.23
5.4.120.0040.02514.14
5.4.110.0090.02014.21
5.4.100.0060.02614.26
5.4.90.0070.02914.11
5.4.80.0060.02914.22
5.4.70.0060.02314.16
5.4.60.0050.01714.09
5.4.50.0090.01914.17
5.4.40.0080.02714.17
5.4.30.0110.01614.25
5.4.20.0080.02314.12
5.4.10.0060.01614.15
5.4.00.0040.02813.93
5.3.290.0020.01813.71
5.3.280.0060.02813.69
5.3.270.0050.01913.66
5.3.260.0050.02013.62
5.3.250.0070.02913.70
5.3.240.0110.02413.68
5.3.230.0040.01613.61
5.3.220.0050.01913.63
5.3.210.0080.02213.66
5.3.200.0110.01913.64
5.3.190.0080.02013.69
5.3.180.0060.01613.70
5.3.170.0050.01713.70
5.3.160.0070.02613.76
5.3.150.0060.02413.65
5.3.140.0060.02813.67
5.3.130.0070.02713.64
5.3.120.0050.02913.66
5.3.110.0060.02713.64
5.3.100.0040.02813.50
5.3.90.0050.02113.49
5.3.80.0060.01613.48
5.3.70.0050.02213.46
5.3.60.0030.02713.54
5.3.50.0020.03013.45
5.3.40.0070.02513.52
5.3.30.0050.02513.34
5.3.20.0060.02713.36
5.3.10.0010.03013.27
5.3.00.0090.02313.25
5.2.170.0060.02411.51
5.2.160.0040.03411.45
5.2.150.0050.02911.46
5.2.140.0030.03411.54
5.2.130.0070.03011.47
5.2.120.0070.02911.41
5.2.110.0060.03011.40
5.2.100.0020.03511.40
5.2.90.0030.03111.44
5.2.80.0030.03511.39
5.2.70.0060.01911.31
5.2.60.0020.03411.38
5.2.50.0060.03011.47
5.2.40.0060.01611.31
5.2.30.0060.01611.33
5.2.20.0080.02711.35
5.2.10.0070.02411.25
5.2.00.0060.03311.03
5.1.60.0070.02210.35
5.1.50.0020.02510.37
5.1.40.0050.02710.42
5.1.30.0020.02710.61
5.1.20.0050.01510.50
5.1.10.0040.02010.43
5.1.00.0050.02810.48
5.0.50.0070.0219.63
5.0.40.0050.0129.63
5.0.30.0030.0329.63
5.0.20.0080.0089.63
5.0.10.0020.0149.63
5.0.00.0000.0219.63
4.4.90.0030.0119.63
4.4.80.0000.0229.63
4.4.70.0020.0139.63
4.4.60.0020.0139.63
4.4.50.0010.0149.63
4.4.40.0020.0149.63
4.4.30.0030.0089.63
4.4.20.0020.0189.63
4.4.10.0000.0209.63
4.4.00.0020.0289.63
4.3.110.0030.0159.63
4.3.100.0060.0129.63
4.3.90.0020.0129.63
4.3.80.0040.0139.63
4.3.70.0020.0109.63
4.3.60.0030.0179.63
4.3.50.0000.0179.63
4.3.40.0030.0209.63
4.3.30.0000.0119.63
4.3.20.0010.0199.63
4.3.10.0010.0149.63
4.3.00.0020.0109.63

preferences:
51.47 ms | 401 KiB | 5 Q