04-04-2008, 04:32 PM
|
#4 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
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.
|
|
|