SOLUTION
$path = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$feedtitle = str_replace(" ", "", $feedtitle);
$feedtitle = strtolower($feedtitle);
$path = substr($path, 0, strrpos($path, "/"));
$feedlink = "http://" . "$path" . "/" . "$feedtitle" . '.xml';
PROBLEM
I am trying to generate a name for an rss feed from another field (feed title). In my query I have :
$path = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$feedtitle = str_replace(" ", "", $feedtitle);
$feedtitle = strtolower($feedtitle);
$feedlink = "$path" . "$feedtitle" . '.xml';
If feedtitle is my rss feed, $feedlink will have the value myrssfeed.xml so that part of the code works but I'm having problems with the path. Instead of writing the current path the above writes the current path & the name of the current file! e.g. if the script I'm using for this is named feedlink.php the path that is stored in the $feedlink variable is :
mywebsite.com/mydir/feedlink.phpmyrssfeed.xml
How do I remove the name of the script?