pyrodude Posted July 13, 2007 Share Posted July 13, 2007 How is it possible to return the current folder's name? I tried explode("\\",getcwd()) but that doesn't seem to work. Basically, getcwd yields C:\path\to\file I want to be able to return just the end (in this case, file) Thanks, sorry for the newb question. Billy Link to comment https://forums.phpfreaks.com/topic/59842-solved-directory/ Share on other sites More sharing options...
micah1701 Posted July 13, 2007 Share Posted July 13, 2007 you're right, probably just not doing it right. if: $fullPath = "C:\path\to\file"; then: $patharray = explode("\",$fullPath); $folder = array_pop($patharray); echo $folder Link to comment https://forums.phpfreaks.com/topic/59842-solved-directory/#findComment-297543 Share on other sites More sharing options...
pyrodude Posted July 14, 2007 Author Share Posted July 14, 2007 That worked (With the slight modification to explode("\\",$filepath); Thanks also for opening my eyes to the fun world of array_pop (better than my method, which was to count the array and then pull the value for the last element) Billy Link to comment https://forums.phpfreaks.com/topic/59842-solved-directory/#findComment-298270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.