Title / Description
Code <?php function foo13($path, $consult) { if($path[0] == '/') { $path = '/'.$path; } if($consult[0] == '/') { $consult = '/'.$consult; } $i = $k = 0; while($path[$i] == $consult[$i]) { if($path[$i] == '/') { $k = $i; } $i++; } if($n = substr_count(substr($path, $k+1), '/')) { return str_repeat('../', $n).substr($consult, $k+1); } return './'. substr($consult, $k+1); } ?>
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code