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.0120.00318.56
8.3.50.0120.00822.05
8.3.40.0160.00318.84
8.3.30.0060.00819.02
8.3.20.0070.00020.33
8.3.10.0080.00021.84
8.3.00.0080.00019.38
8.2.180.0150.00718.43
8.2.170.0120.00322.96
8.2.160.0100.00320.43
8.2.150.0070.00024.18
8.2.140.0050.00524.66
8.2.130.0000.00726.16
8.2.120.0050.00322.25
8.2.110.0060.00320.38
8.2.100.0060.00618.03
8.2.90.0050.00319.24
8.2.80.0050.00317.97
8.2.70.0060.00317.75
8.2.60.0050.00318.05
8.2.50.0050.00918.07
8.2.40.0040.00420.07
8.2.30.0000.00818.04
8.2.20.0000.00717.75
8.2.10.0080.00018.23
8.2.00.0040.00417.79
8.1.280.0090.00625.92
8.1.270.0080.00023.74
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.79
8.1.230.0110.00019.12
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.00817.23
8.1.190.0050.00317.22
8.1.180.0090.00018.10
8.1.170.0000.00818.36
8.1.160.0050.00221.87
8.1.150.0070.00018.85
8.1.140.0080.00017.43
8.1.130.0000.00717.83
8.1.120.0030.00317.46
8.1.110.0050.00317.36
8.1.100.0000.00717.39
8.1.90.0040.00417.35
8.1.80.0000.00817.39
8.1.70.0000.00717.47
8.1.60.0050.00317.61
8.1.50.0060.00617.48
8.1.40.0040.00417.51
8.1.30.0060.00317.45
8.1.20.0040.00417.55
8.1.10.0050.00217.42
8.1.00.0000.00817.45
8.0.300.0030.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00818.36
8.0.270.0000.00717.18
8.0.260.0000.00617.17
8.0.250.0030.00317.02
8.0.240.0070.00016.92
8.0.230.0040.00416.95
8.0.220.0040.00416.90
8.0.210.0000.00716.76
8.0.200.0060.00316.93
8.0.190.0040.00416.96
8.0.180.0040.00316.95
8.0.170.0040.00416.97
8.0.160.0050.00316.94
8.0.150.0000.00716.88
8.0.140.0040.00416.72
8.0.130.0030.00313.37
8.0.120.0050.00316.73
8.0.110.0070.00016.92
8.0.100.0000.00816.84
8.0.90.0000.00816.77
8.0.80.0120.00616.89
8.0.70.0040.00416.73
8.0.60.0000.00716.70
8.0.50.0030.00516.84
8.0.30.0080.01017.15
8.0.20.0060.01217.40
8.0.10.0080.00016.90
8.0.00.0110.00716.81
7.4.330.0050.00215.00
7.4.320.0090.00016.46
7.4.300.0000.00616.55
7.4.290.0000.00716.57
7.4.280.0040.00416.57
7.4.270.0070.00016.50
7.4.260.0030.00316.54
7.4.250.0000.00816.42
7.4.240.0030.00316.55
7.4.230.0000.00716.58
7.4.220.0100.00716.58
7.4.210.0120.00616.58
7.4.200.0040.00416.63
7.4.160.0130.00316.54
7.4.150.0080.01617.40
7.4.140.0050.01217.86
7.4.130.0100.00716.53
7.4.120.0100.00716.46
7.4.110.0060.01016.47
7.4.100.0110.00616.57
7.4.90.0060.01316.46
7.4.80.0060.01819.39
7.4.70.0120.00416.46
7.4.60.0100.00716.47
7.4.50.0030.00516.52
7.4.40.0090.01216.45
7.4.30.0150.00816.40
7.4.00.0050.01214.96
7.3.330.0060.00013.24
7.3.320.0000.00513.29
7.3.310.0040.00416.20
7.3.300.0030.00316.12
7.3.290.0180.00316.28
7.3.280.0090.00616.33
7.3.270.0060.01217.40
7.3.260.0120.00616.52
7.3.250.0090.00716.51
7.3.240.0170.00916.36
7.3.230.0090.00816.60
7.3.210.0060.01016.53
7.3.200.0150.00819.39
7.3.190.0100.01316.59
7.3.180.0040.01216.31
7.3.170.0130.00616.48
7.3.160.0160.00716.56
7.3.120.0070.01014.82
7.3.110.0050.01014.94
7.3.100.0040.01014.78
7.3.90.0020.01114.63
7.3.80.0050.00614.79
7.3.70.0030.00914.75
7.3.60.0060.00914.88
7.3.50.0090.00414.61
7.3.40.0050.01114.61
7.3.30.0020.01014.84
7.3.20.0050.00616.71
7.3.10.0000.01416.58
7.3.00.0030.00916.67
7.2.330.0110.00716.79
7.2.320.0180.00016.68
7.2.310.0080.00816.49
7.2.300.0160.00016.77
7.2.290.0140.00916.64
7.2.250.0060.01315.36
7.2.240.0050.01215.04
7.2.230.0050.00815.18
7.2.220.0060.00715.09
7.2.210.0070.00514.99
7.2.200.0030.01215.08
7.2.190.0060.00914.97
7.2.180.0100.00615.10
7.2.170.0030.01115.12
7.2.00.0030.00619.53
7.1.330.0040.01215.79
7.1.320.0060.00315.81
7.1.310.0070.00515.78
7.1.300.0050.00815.58
7.1.290.0070.00715.87
7.1.280.0060.00315.64
7.1.270.0050.00615.88
7.1.260.0110.00515.72
7.1.100.0030.00918.04
7.1.70.0000.00817.04
7.1.60.0060.01619.32
7.1.50.0240.00934.88
7.1.00.0000.08022.42
7.0.200.0030.00616.88
7.0.140.0030.07322.12
7.0.60.0030.04319.96
7.0.50.0070.05017.88
7.0.40.0170.07320.18
7.0.30.0230.06320.16
7.0.20.0200.04320.22
7.0.10.0070.05020.23
7.0.00.0100.08720.05
5.6.280.0100.06721.08
5.6.210.0000.08320.52
5.6.200.0130.08018.27
5.6.190.0200.05320.64
5.6.180.0400.06720.48
5.6.170.0070.05020.54
5.6.160.0070.05320.71
5.6.150.0100.08018.29
5.6.140.0130.06318.28
5.6.130.0130.07318.11
5.6.120.0030.09321.01
5.6.110.0100.08021.02
5.6.100.0130.06321.04
5.6.90.0070.05720.88
5.6.80.0130.06320.54
5.5.350.0070.07320.43
5.5.340.0030.04017.95
5.5.330.0030.08320.47
5.5.320.0330.07320.51
5.5.310.0200.08320.25
5.5.300.0030.08317.95
5.5.290.0100.04717.92
5.5.280.0070.08320.77
5.5.270.0200.07020.89
5.5.260.0100.06720.79
5.5.250.0030.08020.58
5.5.240.3930.03320.26
5.4.450.0330.02319.44
5.4.440.0230.04019.25
5.4.430.0270.03319.48
5.4.420.0930.00019.53
5.4.410.0670.00019.28
5.4.400.0800.00019.13
5.4.390.0630.00019.16
5.4.380.0630.00019.11
5.4.370.0630.00019.15
5.4.360.0600.00019.02
5.4.350.0670.00019.07
5.4.340.0070.03412.02
5.4.320.0050.03712.51
5.4.310.0090.03512.50
5.4.300.0060.04412.50
5.4.290.0050.04112.50
5.4.280.0080.03412.40
5.4.270.0050.03612.40
5.4.260.0060.03812.40
5.4.250.0030.04012.39
5.4.240.0100.03712.40
5.4.230.0050.04012.39
5.4.220.0070.03912.39
5.4.210.0090.03912.39
5.4.200.0050.03912.39
5.4.190.0090.04412.39
5.4.180.0060.03912.38
5.4.170.0040.03712.39
5.4.160.0080.04412.39
5.4.150.0050.04312.39
5.4.140.0050.03912.07
5.4.130.0060.03512.06
5.4.120.0050.03612.02
5.4.110.0070.03412.02
5.4.100.0090.03312.02
5.4.90.0100.03912.01
5.4.80.0060.04012.01
5.4.70.0050.03612.01
5.4.60.0030.03712.01
5.4.50.0040.03712.01
5.4.40.0070.03311.99
5.4.30.0050.04011.99
5.4.20.0080.03311.99
5.4.10.0090.03211.99
5.4.00.0090.04211.48
5.3.290.0070.03812.80
5.3.280.0060.03812.70
5.3.270.0060.03812.73
5.3.260.0070.03712.72
5.3.250.0060.03712.71
5.3.240.0030.04012.72
5.3.230.0040.04012.71
5.3.220.0080.03612.68
5.3.210.0060.04912.68
5.3.200.0030.04712.68
5.3.190.0060.03712.68
5.3.180.0050.03712.67
5.3.170.0050.03712.67
5.3.160.0060.03712.68
5.3.150.0050.04412.67
5.3.140.0090.03312.66
5.3.130.0060.03912.66
5.3.120.0100.04212.66
5.3.110.0100.03612.66
5.3.100.0050.03612.12
5.3.90.0050.03712.10
5.3.80.0030.03912.09
5.3.70.0080.03812.09
5.3.60.0050.03712.08
5.3.50.0070.04312.02
5.3.40.0100.03712.03
5.3.30.0050.04011.98
5.3.20.0060.03611.76
5.3.10.0080.03611.73
5.3.00.0070.03811.72
5.2.170.0100.0279.23
5.2.160.0060.0299.23
5.2.150.0060.0299.23
5.2.140.0040.0309.23
5.2.130.0040.0399.18
5.2.120.0030.0309.18
5.2.110.0030.0309.19
5.2.100.0020.0319.19
5.2.90.0040.0309.19
5.2.80.0020.0329.18
5.2.70.0040.0319.18
5.2.60.0030.0329.14
5.2.50.0060.0329.11
5.2.40.0030.0329.09
5.2.30.0040.0339.06
5.2.20.0070.0289.05
5.2.10.0060.0298.95
5.2.00.0070.0298.82
5.1.60.0080.0238.10
5.1.50.0050.0258.10
5.1.40.0070.0218.08
5.1.30.0060.0248.43
5.1.20.0080.0298.45
5.1.10.0070.0238.18
5.1.00.0050.0268.18
5.0.50.0050.0206.65
5.0.40.0030.0216.52
5.0.30.0010.0346.33
5.0.20.0060.0166.29
5.0.10.0060.0196.27
5.0.00.0070.0286.27
4.4.90.0030.0164.78
4.4.80.0030.0184.75
4.4.70.0030.0154.76
4.4.60.0040.0144.76
4.4.50.0010.0174.77
4.4.40.0030.0254.71
4.4.30.0020.0164.76
4.4.20.0040.0174.84
4.4.10.0020.0194.85
4.4.00.0040.0244.76
4.3.110.0030.0164.66
4.3.100.0050.0134.66
4.3.90.0040.0144.63
4.3.80.0010.0274.59
4.3.70.0040.0154.63
4.3.60.0040.0134.63
4.3.50.0040.0144.63
4.3.40.0020.0254.54
4.3.30.0010.0173.32
4.3.20.0010.0173.30
4.3.10.0020.0163.26
4.3.00.0030.01713.21

preferences:
46.05 ms | 401 KiB | 5 Q