Getting relative path from absolute path in PHP
Try this one: function getRelativePath($from, $to) { // some compatibility fixes for Windows paths $from = is_dir($from) ? rtrim($from, ‘\/’) . “https://stackoverflow.com/” : $from; $to = is_dir($to) ? rtrim($to, ‘\/’) . “https://stackoverflow.com/” : $to; $from = str_replace(‘\\’, “https://stackoverflow.com/”, $from); $to = str_replace(‘\\’, “https://stackoverflow.com/”, $to); $from = explode(“https://stackoverflow.com/”, $from); $to = explode(“https://stackoverflow.com/”, $to); $relPath = $to; … Read more