FindRelativePath 함수 [path는 상대적인 관계를 찾아내]
PHP 함수 : 경로 사이의 상대를 찾을 수있다.
PHP 함수 : 친척 관계 사이의 경로를 찾을 수있습니다.
예 :
1 2 3 4 5 6 7 8 9 | <? PHP는 'http://www.php.net/manual/en/install.php' ; $ path_a = 'http://www.php.net/manual/en/install.php'; 'http://www.php.net/downloads' ; $ = path_b 'http://www.php.net/downloads'; Path A: " . $path_a ; "\ n 경로 :"에코. $ path_a; Path B: " . $path_b ; "\ n 경로 B 조 :"에코. $ path_b; A to B: " . findRelativePath ( $path_a , $path_b ) ; // ../../downloads/ "\ B에게 한 n 에코 :". findRelativePath ($ path_a, $ path_b); / / ... / ... / 다운로드 / B to A: " . findRelativePath ( $path_b , $path_a ) ; // ../manual/en/install.php A에게 "\ n B 조 :"에코. findRelativePath ($ path_b, $ path_a); / / ... / 설명서 / 영 / install.php를 ?> |
기능 :
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 ) 함수 findRelativePath ($ path_1, $ path_2) ( $path_1 == "" || $path_2 == "" ) ($ path_1 == ""| | $ path_2면 == "") ( ; 돌아 거짓; ) "/^(\\/|\w:\\/|https?:\\/\\/[^\\/]+\\/)?(.*)$/i" , $path_1 , $matches_1 , PREG_SET_ORDER ) ; 는 preg_match_all ( "/ ^ (\ \ / | \ 승 : \ \ / |은 https? : \ \ / \ \ / [^ \ \ /] + \ \ /)?(.*)$/ 난", $ path_1, $ matches_1, PREG_SET_ORDER); "/^(\\/|\w:\\/|https?:\\/\\/[^\\/]+\\/)?(.*)$/i" , $path_2 , $matches_2 , PREG_SET_ORDER ) ; 는 preg_match_all ( "/ ^ (\ \ / | \ 승 : \ \ / |은 https? : \ \ / \ \ / [^ \ \ /] + \ \ /)?(.*)$/ 난", $ path_2, $ matches_2, PREG_SET_ORDER); $matches_1 [ 0 ] [ 1 ] != $matches_2 [ 0 ] [ 1 ] ) ($ matches_1 [0] [1] 만약! = $ matches_2 [0] [1]) ( ; 돌아 거짓; ) explode ( "/" , $matches_1 [ 0 ] [ 2 ] ) ; $ path_1_parts 폭발 = ( "/", $ matches_1 [0] [2]); explode ( "/" , $matches_2 [ 0 ] [ 2 ] ) ; $ path_2_parts 폭발 = ( "/", $ matches_2 [0] [2]); isset ( $path_1_parts [ 0 ] ) && isset ( $path_2_parts [ 0 ] ) ) (isset ($ path_1_parts [0]) & & isset ($ path_2_parts하면서 [0])) ( $path_1_parts [ 0 ] != $path_2_parts [ 0 ] ) ($ 경우 path_1_parts [0]! = $ path_2_parts [0]) ( 휴식 시간; ) $path_1_parts ) ; ($ path_1_parts) array_shift; $path_2_parts ) ; ($ path_2_parts) array_shift; ) $i = 0 , $path = "" ; $i < count ( $path_1_parts ) - 1 ; $i ++ ) ($ 위해 전 = 0, $ 경로 = ""; $ i가 <() - 1; $ 나 + +) $ path_1_parts 카운트 ( "../" ; $ 경로 .= "../"; ) . implode ( "/" , $path_2_parts ) ; 경로 $ 반환합니다. ( "/", $ path_2_parts) 내파; ) ?> |
| 이 기사에 대한 - 환영 등급 |
지난 180 days.Who 내에서 기부금을 기부 없음 여기에 메세지를 남길 것이다. 자 기부했다.
이것은 WordPress의 플러그인 Wp - Donators. 그것은 지불이 컨테이너에 스폰서 정보 autoleave에 기부 스마트 기능을 제공합니다. 사람을 기부할 수있습니다와 이름 / URL 또는 textlink 광고를 제출했다. 최신 기증자의 정보 구름에 표시됩니다. , 그들의 연결을 '미래에서 가장 큰 인기를 지불 인터페이스를 지원한다 be.It 것이다 더 많은 사람을 기부했다. ParPal 그냥 첫 한. 더많은 ..
문서 Powered by : 포스트 - Donators
로그 - 관련 | 이 신문에서는 독자는 또한 다음에 대해 우려하고있다 :
|















































난 - 무슨 연임에 문제는 아래의 코드 편집기 플러그인 감사에게 묻고 싶다
대답wp를 - codebox
대답