1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| <? Php
$path_1 , $path_2 ) functie findRelativePath ($ path_1, $ path_2)
(
$path_1 == "" || $path_2 == "" ) if ($ path_1 == "" | | $ path_2 == "")
(
; return false;
)
"/^( \\ /| \w : \\ /|https?: \\ / \\ /[^ \\ /] \\ /)?(.*)$/i" , $path_1 , $matches_1 , PREG_SET_ORDER ) ; preg_match_all ( "/ ^ (\ \ / | \ w: \ \ / | https?: \ \ / \ \ / [^ \ \ /] \ \ /)?(.*)$/ i", $ path_1, $ Matches_1, PREG_SET_ORDER);
"/^( \\ /| \w : \\ /|https?: \\ / \\ /[^ \\ /] \\ /)?(.*)$/i" , $path_2 , $matches_2 , PREG_SET_ORDER ) ; preg_match_all ( "/ ^ (\ \ / | \ w: \ \ / | https?: \ \ / \ \ / [^ \ \ /] \ \ /)?(.*)$/ i", $ path_2, $ Matches_2, PREG_SET_ORDER);
$matches_1 [ 0 ] [ 1 ] != $matches_2 [ 0 ] [ 1 ] ) if ($ matches_1 [0] [1]! = $ matches_2 [0] [1])
(
; return false;
)
explode ( "/" , $matches_1 [ 0 ] [ 2 ] ) ; $ Path_1_parts = exploderen ( "/", $ matches_1 [0] [2]);
explode ( "/" , $matches_2 [ 0 ] [ 2 ] ) ; $ Path_2_parts = exploderen ( "/", $ matches_2 [0] [2]);
isset ( $path_1_parts [ 0 ] ) && isset ( $path_2_parts [ 0 ] ) ) while (isset ($ path_1_parts [0]) & & isset ($ path_2_parts [0]))
(
$path_1_parts [ 0 ] != $path_2_parts [ 0 ] ) if ($ path_1_parts [0]! = $ path_2_parts [0])
(
break;
)
$path_1_parts ) ; array_shift ($ path_1_parts);
$path_2_parts ) ; array_shift ($ path_2_parts);
)
$i = 0 , $path = "" ; $i < count ( $path_1_parts ) - 1 ; $i ) for ($ i = 0, $ path = ""; $ i <count ($ path_1_parts) - 1; $ i )
(
"../" ; $ Pad .= "../";
)
. implode ( "/" , $path_2_parts ) ; return $ pad. implode ( "/", $ path_2_parts);
)
?> |
Ik zou graag willen dat de code editor plug-in wat haalbaar is in het kader van de problemen te vertellen Dank u
Antwoordenwp-codebox
Antwoorden