original_string: private static function getRelativePath($from, $to)
      {
          $from = explode('/', $from);
          $to = explode('/', $to);
          $relPath = $to;
  
          foreach ($from as $depth => $dir) {
              // find first non-matching dir
              if (isset($to[$depth]) && $dir === $to[$depth]) {
                  // ignore this directory
                  array_shift($relPath);
              } else {
                  // get number of remaining dirs to $from
                  $remaining = count($from) - $depth;
                  if ($remaining > 1) {
                      // add traversals up to first matching dir
                      $padLength = (count($relPath) + $remaining - 1) * -1;
                      $relPath = array_pad($relPath, $padLength, '..');
                      break;
                  } else {
                      $relPath[0] = './'.$relPath[0];
                  }
              }
          }
  
          return implode('/', $relPath);
      }
code: private static function getRelativePath($from, $to)
      {
          $from = explode('/', $from);
          $to = explode('/', $to);
          $relPath = $to;
  
          foreach ($from as $depth => $dir) {
              // find first non-matching dir
              if (isset($to[$depth]) && $dir === $to[$depth]) {
                  // ignore this directory
                  array_shift($relPath);
              } else {
                  // get number of remaining dirs to $from
                  $remaining = count($from) - $depth;
                  if ($remaining > 1) {
                      // add traversals up to first matching dir
                      $padLength = (count($relPath) + $remaining - 1) * -1;
                      $relPath = array_pad($relPath, $padLength, '..');
                      break;
                  } else {
                      $relPath[0] = './'.$relPath[0];
                  }
              }
          }
  
          return implode('/', $relPath);
      }
code_tokens: private static function getRelativePath ( $ from , $ to ) { $ from = explode ( '/' , $ from ) ; $ to = explode ( '/' , $ to ) ; $ relPath = $ to ; foreach ( $ from as $ depth => $ dir ) { // find first non-matching dir if ( isset ( $ to [ $ depth ] ) && $ dir === $ to [ $ depth ] ) { // ignore this directory array_shift ( $ relPath ) ; } else { // get number of remaining dirs to $from $ remaining = count ( $ from ) - $ depth ; if ( $ remaining > 1 ) { // add traversals up to first matching dir $ padLength = ( count ( $ relPath ) + $ remaining - 1 ) * - 1 ; $ relPath = array_pad ( $ relPath , $ padLength , '..' ) ; break ; } else { $ relPath [ 0 ] = './' . $ relPath [ 0 ] ; } } } return implode ( '/' , $ relPath ) ; }
docstring: Returns a relative path based on 2 absolute paths.
  
  @param string $from
  @param string $to
  
  @return string
docstring_tokens: Returns a relative path based on 2 absolute paths .