3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * * Find the relative file system path between two file system paths * * @param string $frompath Path to start from * @param string $topath Path we want to end up in * * @return string Path leading from $frompath to $topath */ function find_relative_path ( $frompath, $topath ) { $from = explode( DIRECTORY_SEPARATOR, $frompath ); // Folders/File $to = explode( DIRECTORY_SEPARATOR, $topath ); // Folders/File $relpath = ''; $i = 0; // Find how far the path is the same while ( isset($from[$i]) && isset($to[$i]) ) { if ( $from[$i] != $to[$i] ) break; $i++; } $j = count( $from ) - 1; // Add '..' until the path is the same while ( $i <= $j ) { if ( !empty($from[$j]) ) $relpath .= '..'.DIRECTORY_SEPARATOR; $j--; } // Go to folder from where it starts differing while ( isset($to[$i]) ) { if ( !empty($to[$i]) ) $relpath .= $to[$i].DIRECTORY_SEPARATOR; $i++; } // Strip last separator return substr($relpath, 0, -1); } var_dump(find_relative_path('D:/test/pokus/a.txt', 'D:/test/some/file'));

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.0170.00318.55
8.3.50.0150.00521.98
8.3.40.0070.01118.84
8.3.30.0070.00719.21
8.3.20.0070.00020.21
8.3.10.0050.00321.96
8.3.00.0040.00419.38
8.2.180.0080.00816.63
8.2.170.0140.00722.96
8.2.160.0100.00320.29
8.2.150.0070.01124.18
8.2.140.0060.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00422.14
8.2.110.0030.00620.52
8.2.100.0070.00718.22
8.2.90.0030.00519.25
8.2.80.0040.00417.97
8.2.70.0000.00817.50
8.2.60.0050.00317.80
8.2.50.0120.00418.07
8.2.40.0040.00420.07
8.2.30.0040.00418.04
8.2.20.0000.00817.67
8.2.10.0040.00418.05
8.2.00.0060.00317.81
8.1.280.0070.00725.92
8.1.270.0080.00023.97
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0090.00023.93
8.1.230.0070.00419.10
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0060.00317.23
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0080.00018.58
8.1.160.0020.00522.05
8.1.150.0070.00018.85
8.1.140.0000.00717.45
8.1.130.0030.00317.75
8.1.120.0040.00417.54
8.1.110.0040.00417.45
8.1.100.0040.00417.45
8.1.90.0000.00817.50
8.1.80.0000.00717.37
8.1.70.0000.00717.41
8.1.60.0040.00417.63
8.1.50.0000.01017.49
8.1.40.0040.00417.54
8.1.30.0000.00817.65
8.1.20.0000.00817.69
8.1.10.0040.00417.52
8.1.00.0040.00417.44
8.0.300.0030.00518.77
8.0.290.0070.00016.58
8.0.280.0000.00718.43
8.0.270.0030.00317.26
8.0.260.0030.00317.13
8.0.250.0030.00316.85
8.0.240.0070.00016.86
8.0.230.0050.00217.01
8.0.220.0070.00016.97
8.0.210.0000.00716.80
8.0.200.0070.00316.98
8.0.190.0060.00317.00
8.0.180.0000.00716.81
8.0.170.0040.00416.84
8.0.160.0000.00716.77
8.0.150.0040.00416.77
8.0.140.0040.00416.91
8.0.130.0030.00313.36
8.0.120.0040.00416.75
8.0.110.0000.00716.80
8.0.100.0000.00716.75
8.0.90.0070.00316.79
8.0.80.0090.00616.96
8.0.70.0000.00716.76
8.0.60.0050.00216.68
8.0.50.0000.00816.84
8.0.30.0130.00816.91
8.0.20.0130.00617.40
8.0.10.0040.00416.98
8.0.00.0080.01216.89
7.4.330.0000.00615.00
7.4.320.0090.00016.59
7.4.300.0060.00016.49
7.4.290.0030.00316.51
7.4.280.0040.00416.55
7.4.270.0030.00316.56
7.4.260.0000.00716.39
7.4.250.0040.00416.48
7.4.240.0050.00216.49
7.4.230.0070.00016.63
7.4.220.0030.01516.54
7.4.210.0030.01016.57
7.4.200.0000.00716.35
7.4.160.0060.00916.45
7.4.150.0150.00317.40
7.4.140.0130.00817.86
7.4.130.0090.01116.49
7.4.120.0120.00816.50
7.4.110.0070.01016.55
7.4.100.0070.01016.50
7.4.90.0060.01216.59
7.4.80.0060.01819.39
7.4.70.0070.01016.48
7.4.60.0090.00916.65
7.4.50.0030.00516.43
7.4.40.0070.01416.26
7.4.30.0140.01116.48
7.4.00.0030.01415.07
7.3.330.0000.00513.31
7.3.320.0050.00013.26
7.3.310.0030.00516.16
7.3.300.0000.00716.22
7.3.290.0130.00316.31
7.3.280.0070.01016.31
7.3.270.0130.00317.40
7.3.260.0230.00016.50
7.3.250.0100.00516.45
7.3.240.0110.00516.51
7.3.230.0130.00316.55
7.3.210.0170.00016.61
7.3.200.0100.00719.39
7.3.190.0070.01016.34
7.3.180.0120.00316.32
7.3.170.0110.00516.45
7.3.160.0120.00616.38
7.3.10.0050.01216.61
7.3.00.0180.00516.63
7.2.330.0110.00616.72
7.2.320.0120.00616.89
7.2.310.0120.00616.50
7.2.300.0060.00916.41
7.2.290.0070.01716.50
7.2.130.0100.01016.77
7.2.120.0140.00816.85
7.2.110.0120.00616.72
7.2.100.0100.00616.82
7.2.90.0100.00816.77
7.2.80.0060.00816.78
7.2.70.0030.01016.49
7.2.60.0090.00716.88
7.2.50.0170.00216.91
7.2.40.0080.00716.98
7.2.30.0100.00816.60
7.2.20.0070.01016.67
7.2.10.0100.00816.65
7.2.00.0060.01017.65
7.1.250.0090.00915.57
7.1.200.0060.00615.62
7.1.100.0550.00615.87
7.1.70.0040.00417.00
7.1.60.0090.01619.32
7.1.50.0100.02434.65
7.1.00.0030.07722.27
7.0.200.0070.00716.46
7.0.140.0030.07321.92
7.0.60.0170.06719.91
7.0.50.0000.08717.79
7.0.40.0000.09020.21
7.0.30.0500.05320.15
7.0.20.0430.07320.24
7.0.10.0000.05020.24
7.0.00.0230.06020.15
5.6.280.0000.07721.04
5.6.210.0100.07720.73
5.6.200.0070.08318.15
5.6.190.0130.04720.61
5.6.180.0330.07720.48
5.6.170.0170.04320.50
5.6.160.0100.05020.57
5.6.150.0000.04318.25
5.6.140.0130.07718.33
5.6.130.0070.08718.28
5.6.120.0070.05720.90
5.6.110.0170.08021.12
5.6.100.0070.05721.09
5.6.90.0100.05320.96
5.6.80.0170.07020.37
5.6.70.3670.04320.42
5.5.350.0000.08720.41
5.5.340.0130.06318.05
5.5.330.0000.04320.48
5.5.320.0230.07720.24
5.5.310.0270.07720.34
5.5.300.0130.06017.97
5.5.290.0030.04018.07
5.5.280.0130.03720.66
5.5.270.0170.06320.64
5.5.260.0030.09020.79
5.5.250.0030.04020.58
5.5.240.0170.04020.26
5.4.450.0230.04319.39
5.4.440.0170.04019.39
5.4.430.0230.04719.48
5.4.420.0670.00019.53
5.4.410.0900.00019.45
5.4.400.0630.00019.25
5.4.390.0630.00019.03
5.4.380.0700.00019.25
5.4.370.0670.00019.04
5.4.360.0600.00018.98
5.4.350.0670.00019.16
5.4.340.0070.03512.01
5.4.320.0070.03712.50
5.4.310.0050.04112.50
5.4.300.0080.04012.50
5.4.290.0050.04412.50
5.4.280.0120.03412.40
5.4.270.0060.04012.40
5.4.260.0040.03912.40
5.4.250.0030.04012.40
5.4.240.0040.03712.39
5.4.230.0050.04012.39
5.4.220.0110.04012.39
5.4.210.0050.04212.39
5.4.200.0090.03312.39
5.4.190.0110.03712.38
5.4.180.0030.03912.39
5.4.170.0050.03612.39
5.4.160.0030.04012.39
5.4.150.0050.03812.39
5.4.140.0080.04012.07
5.4.130.0060.03612.06
5.4.120.0060.03512.02
5.4.110.0050.03812.02
5.4.100.0060.03512.01
5.4.90.0040.03912.01
5.4.80.0070.03512.01
5.4.70.0080.03212.01
5.4.60.0020.03912.01
5.4.50.0050.03712.01
5.4.40.0060.03411.99
5.4.30.0040.03611.99
5.4.20.0090.03312.00
5.4.10.0030.03811.99
5.4.00.0080.03811.48
5.3.290.0080.04612.80
5.3.280.0120.03712.71
5.3.270.0070.04212.72
5.3.260.0090.03712.71
5.3.250.0060.03912.72
5.3.240.0050.03912.72
5.3.230.0060.03712.71
5.3.220.0100.03612.68
5.3.210.0100.03912.68
5.3.200.0050.03812.68
5.3.190.0030.04012.68
5.3.180.0060.03612.67
5.3.170.0050.03712.66
5.3.160.0020.04012.67
5.3.150.0040.04912.68
5.3.140.0090.03912.66
5.3.130.0090.03612.66
5.3.120.0080.03712.66
5.3.110.0060.03912.66
5.3.100.0050.03712.12
5.3.90.0110.03212.10
5.3.80.0080.03912.10
5.3.70.0080.04112.09
5.3.60.0110.04112.07
5.3.50.0040.03812.03
5.3.40.0060.03612.02
5.3.30.0020.03811.98
5.3.20.0040.03911.77
5.3.10.0060.03411.73
5.3.00.0060.03711.72
5.2.170.0070.0339.23
5.2.160.0090.0259.23
5.2.150.0050.0309.22
5.2.140.0070.0289.22
5.2.130.0070.0289.18
5.2.120.0080.0259.19
5.2.110.0100.0259.19
5.2.100.0030.0319.19
5.2.90.0050.0299.19
5.2.80.0040.0319.18
5.2.70.0050.0299.18
5.2.60.0060.0359.14
5.2.50.0060.0309.11
5.2.40.0060.0339.08
5.2.30.0000.0349.06
5.2.20.0060.0299.05
5.2.10.0060.0278.96
5.2.00.0100.0328.82
5.1.60.0010.0278.10
5.1.50.0020.0278.10
5.1.40.0020.0278.07
5.1.30.0070.0248.43
5.1.20.0040.0288.45
5.1.10.0070.0258.18
5.1.00.0040.0288.18
5.0.50.0030.0216.65
5.0.40.0040.0196.52
5.0.30.0030.0326.33
5.0.20.0040.0186.30
5.0.10.0050.0186.27
5.0.00.0020.0326.27
4.4.90.0010.0194.78
4.4.80.0050.0134.75
4.4.70.0020.0164.75
4.4.60.0010.0174.76
4.4.50.0020.0184.77
4.4.40.0050.0234.70
4.4.30.0030.0154.76
4.4.20.0060.0124.84
4.4.10.0050.0164.85
4.4.00.0040.0284.76
4.3.110.0030.0164.67
4.3.100.0010.0164.66
4.3.90.0010.0174.63
4.3.80.0050.0224.58
4.3.70.0040.0134.63
4.3.60.0020.0154.63
4.3.50.0010.0174.63
4.3.40.0040.0234.54
4.3.30.0020.0163.32
4.3.20.0020.0163.30
4.3.10.0010.0173.27
4.3.00.0070.01313.21

preferences:
47.6 ms | 401 KiB | 5 Q