Beispiel #1
0
 static function difference($path_origin, $path_destiny)
 {
     if ($path_destiny && $path_destiny[0] == "/") {
         return $path_destiny . (substr($path_destiny, -1) == '/' ? '' : '/');
     }
     $res = array();
     $actual = getcwd();
     $plain_origin = Paths::__resolve($actual, $path_origin);
     $plain_destiny = Paths::__resolve($actual, $path_destiny);
     $sames = array();
     for ($i = 0; isset($plain_origin[$i]) && isset($plain_destiny[$i]); $i++) {
         if ($plain_origin[$i] != $plain_destiny[$i]) {
             break;
         }
         array_push($sames, $plain_origin[$i]);
     }
     // $i == count($same)
     for ($j = count($plain_origin); $j > $i; $j--) {
         $res[] = '..';
     }
     for (; $j < count($plain_destiny); $j++) {
         $res[] = $plain_destiny[$j];
     }
     return implode('/', $res) . '/';
 }