foo13

Php code posted
created at 26 May 22:59

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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);
}
?>
451 Bytes in 3 ms with coderay