- Output for 5.3.0 - 5.3.21, 5.4.0 - 5.4.11
- Parse error: syntax error, unexpected ';' in /in/jAb9j on line 24
Process exited with code 255.
<?php
function path_components($path)
{
$components = array();
while ($path != "." && $path != "/")
{
array_unshift($components, basename($path));
$path = dirname($path);
}
if ($path == "/")
array_unshift($components, "/");
return $components;
}
function path_relative_to($path, $rel)
{
$path_components = path_components($path);
$copy = $path_components;
$rel_components = path_components($rel);
for($i = 0 ; $i < count($rel_components ; ++$i))
{
if ($path_components[$i] == $rel[$i])
array_shift($copy);
else
break;
}
return $copy;
}
var_dump(path_relative_to("/a/b/c", "/"));