original_string: protected function shared($path1, $path2)
      {
          // $path could theoretically be empty (e.g. no path is given), in which
          // case it shouldn't expand to array(''), which would compare to one's
          // root /
          $path1 = $path1 ? explode('/', $path1) : array();
          $path2 = $path2 ? explode('/', $path2) : array();
  
          $shared = array();
  
          // compare paths & strip identical ancestors
          foreach ($path1 as $i => $chunk) {
              if (isset($path2[$i]) && $path1[$i] == $path2[$i]) {
                  $shared[] = $chunk;
              } else {
                  break;
              }
          }
  
          return implode('/', $shared);
      }
code: protected function shared($path1, $path2)
      {
          // $path could theoretically be empty (e.g. no path is given), in which
          // case it shouldn't expand to array(''), which would compare to one's
          // root /
          $path1 = $path1 ? explode('/', $path1) : array();
          $path2 = $path2 ? explode('/', $path2) : array();
  
          $shared = array();
  
          // compare paths & strip identical ancestors
          foreach ($path1 as $i => $chunk) {
              if (isset($path2[$i]) && $path1[$i] == $path2[$i]) {
                  $shared[] = $chunk;
              } else {
                  break;
              }
          }
  
          return implode('/', $shared);
      }
code_tokens: protected function shared ( $ path1 , $ path2 ) { // $path could theoretically be empty (e.g. no path is given), in which // case it shouldn't expand to array(''), which would compare to one's // root / $ path1 = $ path1 ? explode ( '/' , $ path1 ) : array ( ) ; $ path2 = $ path2 ? explode ( '/' , $ path2 ) : array ( ) ; $ shared = array ( ) ; // compare paths & strip identical ancestors foreach ( $ path1 as $ i => $ chunk ) { if ( isset ( $ path2 [ $ i ] ) && $ path1 [ $ i ] == $ path2 [ $ i ] ) { $ shared [ ] = $ chunk ; } else { break ; } } return implode ( '/' , $ shared ) ; }
docstring: Figure out the shared path of 2 locations.
  
  Example:
  /home/forkcms/frontend/core/layout/images/img.gif
  and
  /home/forkcms/frontend/cache/minified_css
  share
  /home/forkcms/frontend
  
  @param string $path1
  @param string $path2
  
  @return string
docstring_tokens: Figure out the shared path of 2 locations .