View Single Post
Old 04-04-2008, 05:32 PM   #4 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

I have wrote this function which may be helpful. It will take the current script path and convert the directory slashes into underscores, so you can put all the XML files in one place.

Index.php file in root: ./xml/index.xml
Index.php file in folder: ./xml/folder_index.xml

php Code:
function getXMLFilename($szXMLPath = './xml', $szPathSep = '/', $szFileSep = '_')
{
    $szDocRoot = $_SERVER['DOCUMENT_ROOT'];
    $szScript = str_replace($szDocRoot, '', $_SERVER['SCRIPT_FILENAME']);

    if(substr($szScript, 0, 1) == $szPathSep)
    {
        $szScript = substr($szScript, 1);
    }
   
    $szScript = str_replace($szPathSep, $szFileSep, $szScript);
    $szScript = $szXMLPath . '/' . preg_replace('~\..+$~i', '.xml', strtolower($szScript));

    if(!file_exists($szScript))
    {
        return false;
    }
   
    return $szScript;
}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
buildakicker (04-04-2008)