PHP URL to File Path

I don’t know why it was so hard to find some code to do this.  I did a few google searches and couldn’t find a simple solution so here’s one that works…

function mh_UrlToFilePath($url="") {
  $sServerName = $_SERVER["SERVER_NAME"];
  $sDocRoot = $_SERVER['DOCUMENT_ROOT'];
  $sUrl = substr($url, 0, strpos($url, "?")); // remove querystring
  $sFilePath = substr($sUrl,strpos($sUrl,$sServerName)+strlen($sServerName));
  $sFilePath = $sDocRoot . $sFilePath;
  $sFilePath = str_replace("/", "\", $sFilePath);
  return $sFilePath;
}
Read previous post:
Flash Player broken in Firefox 3 on Mac OS X

When I installed version 10 of the Flash Player on my macbook pro everything seemed to work ok.  I use...

Close