seb hughes Posted May 25, 2007 Share Posted May 25, 2007 I am able to get the folder name of where a file is in eg /folder/ but I don't knwo how to get the full folder path like: www.example.com/folder1/folder2/folder3/ I know how to get the file and the example.com but not to list all the folders, how can I do this. Quote Link to comment https://forums.phpfreaks.com/topic/52956-getting-full-path/ Share on other sites More sharing options...
Wildbug Posted May 25, 2007 Share Posted May 25, 2007 Not quite sure exactly what you're asking, but check out dirname() and some of the "See also..." commands from that page and tell me if that's what you mean. Or do you want to parse a URL? Quote Link to comment https://forums.phpfreaks.com/topic/52956-getting-full-path/#findComment-261526 Share on other sites More sharing options...
seb hughes Posted May 25, 2007 Author Share Posted May 25, 2007 Not quite sure exactly what you're asking, but check out dirname() and some of the "See also..." commands from that page and tell me if that's what you mean. Or do you want to parse a URL? I wanna do both. Quote Link to comment https://forums.phpfreaks.com/topic/52956-getting-full-path/#findComment-261528 Share on other sites More sharing options...
Wildbug Posted May 25, 2007 Share Posted May 25, 2007 Did you look at dirname() and friends? There are some user comments there, too, that may be helpful in your situation. Basically, you may want something like: if (stripos('http://',$string) === 0) { // URL (http://www.example.com/folder1/folder2/file.html) $parts = explode('/',rtrim('http://',$string)); } else { // Filesystem (c:\folder1\folder2\file.txt) $parts = explode(DIRECTORY_SEPARATOR,$string); } That's just an example; it can probably be written better for your exact purpose. Quote Link to comment https://forums.phpfreaks.com/topic/52956-getting-full-path/#findComment-261543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.