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/', '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.43
8.3.50.0140.00521.95
8.3.40.0120.00618.55
8.3.30.0070.00719.23
8.3.20.0070.00020.16
8.3.10.0000.00821.95
8.3.00.0000.00819.38
8.2.180.0090.00616.48
8.2.170.0140.00722.96
8.2.160.0040.01120.47
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00022.05
8.2.110.0090.00020.58
8.2.100.0000.01217.85
8.2.90.0040.00418.28
8.2.80.0050.00317.97
8.2.70.0090.00017.75
8.2.60.0030.00517.80
8.2.50.0130.00018.07
8.2.40.0000.00819.64
8.2.30.0000.00718.22
8.2.20.0030.00617.67
8.2.10.0060.00318.00
8.2.00.0090.00017.73
8.1.280.0110.00425.92
8.1.270.0050.00223.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00722.22
8.1.230.0080.00321.04
8.1.220.0080.00017.78
8.1.210.0040.00418.96
8.1.200.0030.00617.22
8.1.190.0040.00417.38
8.1.180.0000.00818.10
8.1.170.0050.00318.61
8.1.160.0000.00722.11
8.1.150.0040.00418.94
8.1.140.0000.00817.45
8.1.130.0030.00317.89
8.1.120.0000.00817.44
8.1.110.0040.00417.38
8.1.100.0000.00717.49
8.1.90.0070.00017.47
8.1.80.0050.00317.46
8.1.70.0000.00717.43
8.1.60.0000.00917.63
8.1.50.0060.00617.48
8.1.40.0000.00717.39
8.1.30.0030.00617.61
8.1.20.0000.00817.70
8.1.10.0000.00717.57
8.1.00.0040.00417.47
8.0.300.0040.00419.96
8.0.290.0000.00716.75
8.0.280.0000.00718.37
8.0.270.0000.00717.16
8.0.260.0060.00017.22
8.0.250.0040.00417.03
8.0.240.0000.00916.97
8.0.230.0000.00716.99
8.0.220.0030.00316.88
8.0.210.0030.00316.84
8.0.200.0070.00316.93
8.0.190.0040.00416.85
8.0.180.0000.00716.93
8.0.170.0040.00416.82
8.0.160.0000.00816.91
8.0.150.0080.00016.80
8.0.140.0080.00016.86
8.0.130.0000.00513.35
8.0.120.0030.00616.77
8.0.110.0080.00016.88
8.0.100.0050.00216.67
8.0.90.0040.00416.85
8.0.80.0030.01316.95
8.0.70.0000.00716.68
8.0.60.0040.00416.78
8.0.50.0000.00716.88
8.0.30.0110.01017.07
8.0.20.0100.00817.40
8.0.10.0000.00817.06
8.0.00.0070.01016.74
7.4.330.0080.00115.00
7.4.320.0000.01016.63
7.4.300.0030.00316.41
7.4.290.0030.00316.52
7.4.280.0080.00016.55
7.4.270.0000.00716.41
7.4.260.0030.00316.58
7.4.250.0070.00016.37
7.4.240.0030.00416.57
7.4.230.0070.00016.39
7.4.220.0060.01316.64
7.4.210.0140.00016.68
7.4.200.0040.00416.45
7.4.160.0100.00716.41
7.4.150.0100.01317.40
7.4.140.0090.01017.86
7.4.130.0100.00716.67
7.4.120.0140.00516.51
7.4.110.0100.00616.53
7.4.100.0030.01416.44
7.4.90.0110.00716.66
7.4.80.0130.00419.39
7.4.70.0090.00916.47
7.4.60.0120.00616.45
7.4.50.0040.00416.60
7.4.40.0090.00816.54
7.4.30.0100.01116.53
7.4.00.0090.00915.03
7.3.330.0030.00313.18
7.3.320.0060.00013.14
7.3.310.0070.00016.38
7.3.300.0030.00316.18
7.3.290.0070.00716.30
7.3.280.0030.01116.31
7.3.270.0140.01017.40
7.3.260.0190.00316.40
7.3.250.0120.00916.41
7.3.240.0110.00516.32
7.3.230.0070.01116.39
7.3.210.0120.00316.57
7.3.200.0140.00719.39
7.3.190.0130.00916.43
7.3.180.0040.01216.53
7.3.170.0100.00616.41
7.3.160.0100.01316.23
7.3.120.0060.01014.52
7.3.110.0090.00614.81
7.3.100.0040.00815.01
7.3.90.0100.00314.84
7.3.80.0070.00714.89
7.3.70.0120.00314.75
7.3.60.0030.01014.41
7.3.50.0000.01514.95
7.3.40.0100.00314.85
7.3.30.0090.00014.68
7.3.20.0030.01016.66
7.3.10.0010.01216.45
7.3.00.0080.00616.53
7.2.330.0140.00916.84
7.2.320.0060.01016.79
7.2.310.0140.00316.75
7.2.300.0090.00616.82
7.2.290.0000.01916.52
7.2.250.0040.01215.14
7.2.240.0000.01914.98
7.2.230.0080.00815.27
7.2.220.0000.01415.33
7.2.210.0060.00615.25
7.2.200.0040.01115.11
7.2.190.0060.00314.88
7.2.180.0000.01215.12
7.2.170.0070.00715.25
7.2.130.0080.00617.05
7.2.120.0050.01216.86
7.2.110.0100.00616.73
7.2.100.0150.00816.66
7.2.90.0220.00516.69
7.2.80.0190.00116.61
7.2.70.0120.00516.75
7.2.60.0110.00616.66
7.2.50.0090.00616.77
7.2.40.0100.00716.99
7.2.30.0080.00716.85
7.2.20.0090.00616.67
7.2.10.0110.00316.93
7.2.00.0020.01117.85
7.1.330.0090.00615.92
7.1.320.0100.00715.97
7.1.310.0000.00915.73
7.1.300.0040.00715.81
7.1.290.0080.00615.90
7.1.280.0060.00616.04
7.1.270.0070.00416.05
7.1.260.0000.01615.84
7.1.250.0050.01015.70
7.1.230.0100.00315.56
7.1.220.0190.00015.95
7.1.210.0140.00715.87
7.1.200.0070.00415.89
7.1.190.0160.00315.83
7.1.180.0110.00715.91
7.1.170.0120.00715.72
7.1.160.0130.00515.53
7.1.150.0120.00815.68
7.1.140.0130.00615.80
7.1.130.0090.00915.69
7.1.120.0120.00615.41
7.1.110.0140.00615.92
7.1.100.0270.00815.94
7.1.90.0100.00315.49
7.1.80.0170.00015.95
7.1.70.0040.00716.41
7.1.60.0110.01117.57
7.1.50.0180.01225.21
7.1.40.0150.00015.77
7.1.30.0120.00515.69
7.1.20.0040.01815.91
7.1.10.0120.00315.66
7.1.00.0080.03819.05
7.0.310.0140.00415.36
7.0.300.0140.00515.13
7.0.290.0130.00015.57
7.0.280.0110.00515.48
7.0.270.0120.00415.39
7.0.260.0130.00315.53
7.0.250.0150.00415.34
7.0.240.0050.00915.40
7.0.230.0140.00315.43
7.0.220.0100.00315.66
7.0.210.0110.00515.49
7.0.200.0080.00716.06
7.0.190.0160.00315.49
7.0.180.0080.00815.46
7.0.170.0090.00515.34
7.0.160.0080.00815.32
7.0.150.0060.00615.49
7.0.140.0080.03318.69
7.0.130.0150.00615.51
7.0.120.0120.00015.43
7.0.110.0100.00515.22
7.0.100.0120.00615.31
7.0.90.0160.00415.41
7.0.80.0080.00815.09
7.0.70.0130.00715.48
7.0.60.0050.04517.64
7.0.50.0060.04016.69
7.0.40.0100.04316.68
7.0.30.0130.02916.69
7.0.20.0200.04216.78
7.0.10.0020.05016.96
7.0.00.0110.04016.80
5.6.380.0140.00414.34
5.6.370.0060.01114.55
5.6.360.0110.00514.58
5.6.350.0120.00614.36
5.6.340.0060.00914.59
5.6.330.0090.00414.28
5.6.320.0130.00514.22
5.6.310.0110.00414.44
5.6.300.0040.01314.36
5.6.290.0090.00714.68
5.6.280.0060.04017.65
5.6.270.0110.00314.48
5.6.260.0070.01014.43
5.6.250.0140.00514.57
5.6.240.0080.00814.27
5.6.230.0110.00714.50
5.6.220.0070.00714.35
5.6.210.0110.04017.55
5.6.200.0110.02716.24
5.6.190.0050.03817.38
5.6.180.0150.04417.56
5.6.170.0150.02517.39
5.6.160.0060.04517.35
5.6.150.0070.03916.47
5.6.140.0090.04116.30
5.6.130.0080.02716.25
5.6.120.0080.02617.90
5.6.110.0070.03317.95
5.6.100.0080.04617.66
5.6.90.0080.02617.58
5.6.80.0040.02917.41
5.6.70.2230.02617.40
5.6.60.0070.00714.15
5.6.50.0110.00314.45
5.6.40.0030.00714.47
5.6.30.0000.01114.63
5.6.20.0070.00714.04
5.6.10.0050.00514.47
5.6.00.0070.00714.55
5.5.380.0110.00312.79
5.5.370.0110.00312.79
5.5.360.0040.01112.79
5.5.350.0030.01816.63
5.5.340.0100.03815.44
5.5.330.0080.03716.53
5.5.320.0080.04616.53
5.5.310.0150.04216.57
5.5.300.0100.03315.39
5.5.290.0080.03815.42
5.5.280.0020.02916.83
5.5.270.0030.04916.73
5.5.260.0030.02516.84
5.5.250.0060.04016.69
5.5.240.0240.03316.53
5.5.230.0090.00312.79
5.5.220.0000.00912.79
5.5.210.0030.00612.79
5.5.200.0050.00512.79
5.5.190.0090.00312.79
5.5.180.0070.00312.79
5.5.170.0040.01114.26
5.5.160.0050.00512.79
5.5.150.0060.00612.79
5.5.140.0030.00312.79
5.5.130.0030.00312.79
5.5.120.0000.00712.79
5.5.110.0070.00312.79
5.5.100.0080.00012.79
5.5.90.0060.00612.79
5.5.80.0030.00712.79
5.5.70.0070.00312.79
5.5.60.0040.00812.79
5.5.50.0000.01012.79
5.5.40.0070.00012.79
5.5.30.0030.00612.79
5.5.20.0030.00612.79
5.5.10.0000.00912.79
5.5.00.0090.00312.79
5.4.450.0180.02816.21
5.4.440.0150.02316.06
5.4.430.0180.01716.10
5.4.420.0370.00416.16
5.4.410.0370.00216.04
5.4.400.0380.00216.10
5.4.390.0370.00215.95
5.4.380.0400.00115.94
5.4.370.0360.00315.91
5.4.360.0370.00215.96
5.4.350.0340.00315.93
5.4.340.0080.02212.40
5.4.330.0160.00012.79
5.4.320.0060.02112.65
5.4.310.0090.01912.64
5.4.300.0090.01812.65
5.4.290.0080.02012.65
5.4.280.0100.01812.60
5.4.270.0060.02212.60
5.4.260.0090.02212.59
5.4.250.0070.02112.60
5.4.240.0060.02012.60
5.4.230.0040.02612.59
5.4.220.0050.02112.59
5.4.210.0110.01612.59
5.4.200.0060.02312.59
5.4.190.0090.01812.59
5.4.180.0070.02212.59
5.4.170.0090.01912.59
5.4.160.0040.02112.59
5.4.150.0060.02212.59
5.4.140.0080.02312.43
5.4.130.0060.01912.42
5.4.120.0070.01812.40
5.4.110.0050.02212.40
5.4.100.0050.02012.40
5.4.90.0090.01912.40
5.4.80.0080.01912.40
5.4.70.0070.02012.40
5.4.60.0070.02012.40
5.4.50.0050.02112.40
5.4.40.0080.01912.39
5.4.30.0060.02112.39
5.4.20.0080.01912.39
5.4.10.0090.01912.39
5.4.00.0070.02312.14
5.3.290.0100.02012.79
5.3.280.0070.02112.75
5.3.270.0040.02412.76
5.3.260.0110.01912.75
5.3.250.0030.02312.76
5.3.240.0050.02312.76
5.3.230.0060.02112.75
5.3.220.0090.01812.73
5.3.210.0070.02112.73
5.3.200.0100.02012.74
5.3.190.0040.02212.73
5.3.180.0060.02612.73
5.3.170.0080.02112.73
5.3.160.0060.02112.73
5.3.150.0080.02112.73
5.3.140.0100.01812.72
5.3.130.0040.02512.72
5.3.120.0080.02112.72
5.3.110.0080.02512.72
5.3.100.0030.02312.46
5.3.90.0080.02112.44
5.3.80.0080.02112.44
5.3.70.0050.02512.44
5.3.60.0070.01912.43
5.3.50.0060.01912.41
5.3.40.0060.02312.41
5.3.30.0060.02012.38
5.3.20.0040.02312.28
5.3.10.0100.01812.26
5.3.00.0060.02012.25
5.2.170.0050.01711.01
5.2.160.0020.01911.01
5.2.150.0040.01811.01
5.2.140.0050.02011.01
5.2.130.0050.02210.99
5.2.120.0060.02110.99
5.2.110.0110.01410.99
5.2.100.0080.01510.99
5.2.90.0050.01810.99
5.2.80.0050.01910.99
5.2.70.0050.01910.99
5.2.60.0080.01710.96
5.2.50.0080.01810.95
5.2.40.0050.01710.94
5.2.30.0030.01810.93
5.2.20.0080.01410.92
5.2.10.0070.01510.87
5.2.00.0050.01610.80
5.1.60.0060.01310.45
5.1.50.0060.01510.45
5.1.40.0030.01810.43
5.1.30.0080.01510.61
5.1.20.0060.01710.62
5.1.10.0060.01510.48
5.1.00.0040.02010.48
5.0.50.0070.0109.72
5.0.40.0060.0119.65
5.0.30.0030.0189.56
5.0.20.0050.0119.54
5.0.10.0040.0129.54
5.0.00.0050.0169.53
4.4.90.0050.0098.78
4.4.80.0030.0108.77
4.4.70.0040.0078.77
4.4.60.0040.0078.77
4.4.50.0030.0108.78
4.4.40.0040.0148.75
4.4.30.0030.0118.77
4.4.20.0020.0118.82
4.4.10.0030.0098.82
4.4.00.0040.0148.77
4.3.110.0050.0098.73
4.3.100.0050.0138.73
4.3.90.0040.0118.71
4.3.80.0060.0178.69
4.3.70.0050.0088.71
4.3.60.0040.0088.71
4.3.50.0040.0108.71
4.3.40.0040.0138.66
4.3.30.0010.0138.06
4.3.20.0010.0128.04
4.3.10.0010.0128.03
4.3.00.0060.00813.00

preferences:
43.48 ms | 401 KiB | 5 Q