<?php include ‘../../c/e/one.php‘; echo "\n"; echo ‘this is two‘; echo "\n"; $a = "/a/b/c/d/e.php"; $b = "/a/b/12/34/c.php"; $cnta = strlen($a); $cntb = strlen($b); $cnt = max($cnta,$cntb); echo $cnt,"\n"; for($i=1;$i<$cnt;$i++){ $str_a = substr($a,0,$i); $str_b = substr($b,0,$i); if($str_a == $str_b){ $base = $str_a; }else{ break; } } echo $base,"\n"; $start = strlen($base); $a_arr = explode(‘/‘,substr($a,$start)); $a_c_cnt = count($a_arr)-1; $path = ‘‘; for($i=0;$i<$a_c_cnt;$i++){ $path .= "../"; } $path .= substr($a,$start); echo $path,"\n"; $b_arr = explode(‘/‘,substr($b,$start)); $b_c_cnt = count($b_arr)-1; $path = ‘‘; for($i=0;$i<$b_c_cnt;$i++){ $path .= "../"; } $path .= substr($b,$start); echo $path,"\n";
时间: 2024-10-12 20:23:37