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) { echo $path_components[$i] . " == " . $rel[$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.70.0110.00716.63
8.3.60.0120.00316.63
8.3.50.0120.00522.05
8.3.40.0090.00918.70
8.3.30.0100.00719.04
8.3.20.0040.00420.33
8.3.10.0080.00023.50
8.3.00.0080.00319.12
8.2.190.0150.00018.41
8.2.180.0090.00618.30
8.2.170.0090.00622.96
8.2.160.0070.00720.39
8.2.150.0050.00324.18
8.2.140.0050.00524.66
8.2.130.0070.00026.16
8.2.120.0040.00422.17
8.2.110.0050.00522.21
8.2.100.0080.00417.91
8.2.90.0040.00419.21
8.2.80.0080.00017.97
8.2.70.0060.00317.50
8.2.60.0030.00518.05
8.2.50.0080.00018.07
8.2.40.0000.00818.16
8.2.30.0040.00418.06
8.2.20.0000.00817.64
8.2.10.0000.00717.82
8.2.00.0040.00417.82
8.1.280.0070.00725.92
8.1.270.0050.00323.97
8.1.260.0060.00326.35
8.1.250.0070.00028.09
8.1.240.0060.00323.91
8.1.230.0050.00919.11
8.1.220.0060.00317.79
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0040.00417.41
8.1.180.0080.00018.10
8.1.170.0080.00018.57
8.1.160.0030.00621.91
8.1.150.0040.00418.66
8.1.140.0070.00017.48
8.1.130.0030.00317.91
8.1.120.0000.00717.39
8.1.110.0000.00817.39
8.1.100.0060.00317.44
8.1.90.0040.00417.55
8.1.80.0040.00417.37
8.1.70.0000.00817.32
8.1.60.0000.00917.48
8.1.50.0050.00317.50
8.1.40.0090.00017.54
8.1.30.0050.00317.59
8.1.20.0040.00417.68
8.1.10.0000.00717.61
8.1.00.0070.00317.51
8.0.300.0070.00018.77
8.0.290.0070.00017.03
8.0.280.0030.00318.46
8.0.270.0040.00417.29
8.0.260.0070.00016.94
8.0.250.0070.00017.01
8.0.240.0060.00317.04
8.0.230.0040.00416.94
8.0.220.0040.00416.94
8.0.210.0030.00316.88
8.0.200.0040.00416.89
8.0.190.0040.00416.97
8.0.180.0090.00016.79
8.0.170.0030.00516.98
8.0.160.0000.00816.88
8.0.150.0030.00316.75
8.0.140.0000.00716.84
8.0.130.0050.00013.37
8.0.120.0050.00215.08
8.0.110.0020.00615.05
8.0.100.0060.00115.22
8.0.90.0020.00615.04
8.0.80.0080.00415.08
8.0.70.0040.00415.13
8.0.60.0050.00215.04
8.0.50.0020.00615.13
8.0.30.0060.01215.87
8.0.20.0050.01016.05
8.0.10.0030.00515.15
8.0.00.0070.00815.64
7.4.330.0030.00315.10
7.4.320.0030.00316.48
7.4.300.0030.00316.63
7.4.290.0030.00316.56
7.4.280.0050.00316.52
7.4.270.0040.00416.66
7.4.260.0070.00016.51
7.4.250.0070.00114.82
7.4.240.0040.00315.44
7.4.230.0060.00215.00
7.4.220.0140.00014.98
7.4.210.0070.00715.78
7.4.200.0060.00215.00
7.4.190.0050.00314.93
7.4.180.0020.00513.36
7.4.160.0090.00314.86
7.4.150.0080.00615.35
7.4.140.0080.00616.30
7.4.130.0090.00715.46
7.4.120.0080.00915.45
7.4.110.0100.00515.01
7.4.100.0140.00214.96
7.4.90.0100.00614.91
7.4.80.0120.00616.28
7.4.70.0110.00314.95
7.4.60.0020.01114.90
7.4.50.0020.00614.78
7.4.40.0040.00717.97
7.4.30.0070.00714.77
7.4.20.0080.00013.24
7.4.10.0040.00413.37
7.4.00.0090.00314.29
7.3.330.0050.00013.45
7.3.320.0030.00313.32
7.3.310.0060.00214.87
7.3.300.0000.00614.82
7.3.290.0100.00314.86
7.3.280.0080.00915.58
7.3.270.0100.00315.29
7.3.260.0110.00514.86
7.3.250.0070.00815.49
7.3.240.0060.00814.77
7.3.230.0060.00815.00
7.3.220.0040.00413.30
7.3.210.0110.00414.79
7.3.200.0090.00616.23
7.3.190.0060.00714.91
7.3.180.0090.00314.80
7.3.170.0090.00614.78
7.3.160.0070.00514.85
7.3.150.0060.00013.22
7.3.140.0060.00013.24
7.3.130.0030.00313.11
7.3.120.0010.00713.86
7.3.110.0030.00313.16
7.3.100.0020.00413.01
7.3.90.0000.00613.64
7.3.80.0000.00613.24
7.3.70.0030.00313.52
7.3.60.0060.00013.50
7.3.50.0060.00013.50
7.3.40.0060.00013.48
7.3.30.0060.00013.45
7.3.20.0060.00015.11
7.3.10.0050.00015.02
7.3.00.0060.00015.08
7.2.340.0110.00013.45
7.2.330.0100.00514.96
7.2.320.0100.00514.97
7.2.310.0120.00415.09
7.2.300.0100.00515.06
7.2.290.0100.00515.02
7.2.280.0060.00613.41
7.2.270.0120.00013.48
7.2.260.0100.00213.44
7.2.250.0130.00013.55
7.2.240.0100.00213.42
7.2.230.0120.00013.48
7.2.220.0090.00313.31
7.2.210.0090.00313.49
7.2.200.0090.00413.65
7.2.190.0120.00013.44
7.2.180.0040.00813.69
7.2.170.0080.00513.45
7.2.160.0120.00013.67
7.2.150.0100.00315.46
7.2.140.0080.00415.44
7.2.130.0080.00415.39
7.2.120.0090.00515.53
7.2.110.0080.00515.58
7.2.100.0130.00015.47
7.2.90.0040.00915.32
7.2.80.0100.00315.49
7.2.70.0110.00215.27
7.2.60.0080.00415.46
7.2.50.0130.00015.46
7.2.40.0090.00315.54
7.2.30.0130.00015.33
7.2.20.0050.00915.52
7.2.10.0080.00615.55
7.2.00.0060.00617.34
7.1.330.0090.00314.33
7.1.320.0080.00414.48
7.1.310.0120.00014.18
7.1.300.0100.00214.13
7.1.290.0060.00614.50
7.1.280.0090.00314.34
7.1.270.0070.00414.41
7.1.260.0090.00214.16
7.1.250.0080.00414.30
7.1.240.0000.01114.10
7.1.230.0080.00414.22
7.1.220.0090.00214.39
7.1.210.0100.00214.32
7.1.200.0080.00414.47
7.1.190.0090.00214.18
7.1.180.0090.00314.11
7.1.170.0120.00014.34
7.1.160.0090.00314.19
7.1.150.0080.00414.14
7.1.140.0060.00614.20
7.1.130.0070.00514.11
7.1.120.0100.00214.34
7.1.110.0120.00014.17
7.1.100.0020.00916.36
7.1.90.0090.00314.27
7.1.80.0090.00214.38
7.1.70.0060.00415.62
7.1.60.0070.01216.79
7.1.50.0100.00815.51
7.1.40.0100.00214.23
7.1.30.0080.00514.44
7.1.20.0090.00414.18
7.1.10.0120.00014.37
7.1.00.0030.04218.37
7.0.330.0120.00014.26
7.0.320.0120.00014.20
7.0.310.0040.00714.31
7.0.300.0050.00714.32
7.0.290.0090.00314.06
7.0.280.0000.01214.13
7.0.270.0080.00414.02
7.0.260.0120.00014.22
7.0.250.0100.00314.27
7.0.240.0090.00314.35
7.0.230.0120.00014.39
7.0.220.0060.00614.28
7.0.210.0120.00014.21
7.0.200.0060.00615.55
7.0.190.0090.00214.18
7.0.180.0120.00014.10
7.0.170.0080.00414.36
7.0.160.0060.00614.12
7.0.150.0120.00014.18
7.0.140.0060.03818.10
7.0.130.0110.00014.07
7.0.120.0080.00414.33
7.0.110.0020.04617.07
7.0.100.0100.03617.05
7.0.90.0080.04217.02
7.0.80.0120.02617.13
7.0.70.0100.02217.12
7.0.60.0100.02117.14
7.0.50.0130.02017.27
7.0.40.0090.02317.23
7.0.30.0060.02317.16
7.0.20.0090.02017.23
7.0.10.0030.03817.23
7.0.00.0110.02317.10
5.6.400.0100.00212.68
5.6.390.0090.00212.59
5.6.380.0090.00312.77
5.6.370.0060.00612.55
5.6.360.0110.00012.80
5.6.350.0040.00812.92
5.6.340.0060.00612.75
5.6.330.0110.00012.75
5.6.320.0000.01112.79
5.6.310.0060.00612.94
5.6.300.0080.00412.68
5.6.290.0090.00312.65
5.6.280.0090.03716.78
5.6.270.0070.00412.74
5.6.260.0000.05116.62
5.6.250.0060.04516.67
5.6.240.0090.04016.58
5.6.230.0080.02216.75
5.6.220.0050.02516.66
5.6.210.0070.02216.80
5.6.200.0070.02217.17
5.6.190.0070.03117.11
5.6.180.0060.03017.05
5.6.170.0050.02417.05
5.6.160.0060.02317.11
5.6.150.0090.03217.08
5.6.140.0060.02316.99
5.6.130.0070.03716.97
5.6.120.0070.02717.02
5.6.110.0050.02417.07
5.6.100.0090.02016.94
5.6.90.0060.02116.89
5.6.80.0020.02516.46
5.6.70.0070.02016.71
5.6.60.0050.02216.69
5.6.50.0070.02116.55
5.6.40.0050.02216.58
5.6.30.0070.03016.60
5.6.20.0040.02516.67
5.6.10.0020.02416.78
5.6.00.0090.02216.56
5.5.380.0070.04016.57
5.5.370.0090.03516.63
5.5.360.0060.02416.60
5.5.350.0080.02016.61
5.5.340.0050.02316.85
5.5.330.0060.02316.82
5.5.320.0050.02416.86
5.5.310.0050.03816.73
5.5.300.0080.03016.84
5.5.290.0060.02316.93
5.5.280.0060.02316.87
5.5.270.0030.02616.76
5.5.260.0080.01916.87
5.5.250.0070.02916.76
5.5.240.0090.01816.71
5.5.230.0070.02016.46
5.5.220.0060.02316.64
5.5.210.0070.02516.51
5.5.200.0060.03016.54
5.5.190.0060.03316.44
5.5.180.0050.03016.48
5.5.170.0070.00412.86
5.5.160.0060.02316.36
5.5.150.0050.02116.42
5.5.140.0110.01716.36
5.5.130.0060.03916.35
5.5.120.0070.02316.38
5.5.110.0110.03816.46
5.5.100.0140.02316.58
5.5.90.0100.03516.56
5.5.80.0080.04216.39
5.5.70.0090.04016.40
5.5.60.0050.03916.62
5.5.50.0050.02916.50
5.5.40.0040.04516.50
5.5.30.0090.04016.48
5.5.20.0140.03516.52
5.5.10.0080.02516.39
5.5.00.0090.04016.49
5.4.450.0060.02216.09
5.4.440.0050.02315.97
5.4.430.0050.02216.05
5.4.420.0090.01816.06
5.4.410.0070.02315.93
5.4.400.0090.02115.76
5.4.390.0090.01815.82
5.4.380.0060.02016.03
5.4.370.0070.01815.90
5.4.360.0050.03215.95
5.4.350.0070.01815.98
5.4.340.0080.01816.04
5.4.330.0080.00312.75
5.4.320.0050.02215.94
5.4.310.0100.03015.84
5.4.300.0100.01715.87
5.4.290.0070.01816.09
5.4.280.0070.04215.89
5.4.270.0100.03515.92
5.4.260.0040.03815.94
5.4.250.0090.03916.02
5.4.240.0060.03815.88
5.4.230.0050.04015.69
5.4.220.0090.03815.69
5.4.210.0140.03215.74
5.4.200.0070.02515.67
5.4.190.0090.03715.84
5.4.180.0060.02515.85
5.4.170.0110.03815.83
5.4.160.0140.03515.87
5.4.150.0040.04515.79
5.4.140.0090.03714.62
5.4.130.0050.03814.53
5.4.120.0070.02214.71
5.4.110.0060.04114.50
5.4.100.0080.03914.58
5.4.90.0080.03414.58
5.4.80.0050.02814.66
5.4.70.0090.03714.66
5.4.60.0090.03114.78
5.4.50.0060.03814.61
5.4.40.0080.03814.65
5.4.30.0100.03314.57
5.4.20.0020.03814.57
5.4.10.0070.03014.72
5.4.00.0090.03814.36
5.3.290.0060.01813.98
5.3.280.0030.04613.79
5.3.270.0090.04013.84
5.3.260.0060.03913.79
5.3.250.0090.03813.94
5.3.240.0060.02813.79
5.3.230.0070.04213.78
5.3.220.0100.03813.70
5.3.210.0110.03413.73
5.3.200.0060.04113.83
5.3.190.0070.03413.70
5.3.180.0060.04113.82
5.3.170.0060.02513.97
5.3.160.0130.03213.84
5.3.150.0030.04313.83
5.3.140.0090.03813.71
5.3.130.0070.03913.74
5.3.120.0070.04013.84
5.3.110.0060.04113.83
5.3.100.0070.03513.56
5.3.90.0070.03513.67
5.3.80.0090.03613.43
5.3.70.0060.03813.54
5.3.60.0070.03713.62
5.3.50.0110.03713.46
5.3.40.0090.03713.49
5.3.30.0050.02713.45
5.3.20.0080.03713.43
5.3.10.0120.03213.18
5.3.00.0070.03813.19
5.2.170.0000.03611.84
5.2.160.0100.02411.85
5.2.150.0070.02411.86
5.2.140.0030.01811.91
5.2.130.0050.02911.93
5.2.120.0090.02711.85
5.2.110.0060.03311.83
5.2.100.0060.03111.95
5.2.90.0050.03011.82
5.2.80.0030.03411.76
5.2.70.0070.02811.78
5.2.60.0020.03311.87
5.2.50.0060.02311.83
5.2.40.0060.03111.93
5.2.30.0050.03011.79
5.2.20.0060.03111.82
5.2.10.0020.03411.83
5.2.00.0040.03111.66
5.1.60.0030.02611.46
5.1.50.0050.02311.44
5.1.40.0030.02611.41
5.1.30.0060.02611.45
5.1.20.0040.03011.47
5.1.10.0070.02711.35
5.1.00.0040.01811.30
5.0.50.0030.02511.26
5.0.40.0030.02511.26
5.0.30.0050.03311.26
5.0.20.0070.01711.26
5.0.10.0050.02211.26
5.0.00.0030.02711.26
4.4.90.0040.01611.26
4.4.80.0040.01811.26
4.4.70.0030.01711.26
4.4.60.0020.01511.26
4.4.50.0020.01511.26
4.4.40.0050.02511.26
4.4.30.0020.01811.26
4.4.20.0000.02011.26
4.4.10.0020.01811.26
4.4.00.0000.02811.26
4.3.110.0030.01711.26
4.3.100.0040.00811.26
4.3.90.0020.01811.26
4.3.80.0030.01411.26
4.3.70.0080.01011.26
4.3.60.0050.01311.26
4.3.50.0040.01711.26
4.3.40.0020.02911.26
4.3.30.0030.01711.26
4.3.20.0050.01311.26
4.3.10.0020.01011.26
4.3.00.0020.01611.26

preferences:
61.84 ms | 401 KiB | 5 Q