public static function getRelativePath($from, $to)
{
$from = '/' . trim($from, '/');
$to = '/' . trim($to, '/');
if (0 === ($pos = strpos($from, $to))) {
return substr($from, strlen($to) + ('/' === $to ? 0 : 1));
}
$result = '';
while ($to && false === strpos($from, $to)) {
$result .= '../';
$to = substr($to, 0, strrpos($to, '/'));
}
return !$to ? $result . substr($from, 1) : $result . substr($from, strlen($to) + 1);
}