brem13 Posted February 17, 2009 Share Posted February 17, 2009 ok, im trying to figure out how to link to a previous directory, like i know i can use "$dirname = basename(dirname(__FILE__));" to get the name of the current directory. but say the folders are /public_html/galleries/members/ADMIN/RANDOM <----- RANDOM is the current directory, but how would i write code to take the previous directory 'ADMIN' and put it in a variable????? ive tried "$dirname = basename("../".dirname(__FILE__));" and stuff like that, but it doesnt work????? any help is greatly appreciated Link to comment https://forums.phpfreaks.com/topic/145579-getting-previous-directory-name/ Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 $cwd = getcwd(); $cwd = explode("/", $cwd); $pwd = $cwd[(count($cwd)-2)]; echo $pwd; Should do it for ya. Link to comment https://forums.phpfreaks.com/topic/145579-getting-previous-directory-name/#findComment-764288 Share on other sites More sharing options...
brem13 Posted February 17, 2009 Author Share Posted February 17, 2009 thank you and it kindof works, somehow it puts 'array' into the link for all but one picture. the first picture is fine "galleries/members/BREMINEM/RANDOM/1234963429.jpg", and all the rest are like this now "galleries/members/ADMIN/RANDOM/Array/1234920795.jpg" Link to comment https://forums.phpfreaks.com/topic/145579-getting-previous-directory-name/#findComment-764293 Share on other sites More sharing options...
brem13 Posted February 17, 2009 Author Share Posted February 17, 2009 nevermind, i got it, thank you sooo much!! Link to comment https://forums.phpfreaks.com/topic/145579-getting-previous-directory-name/#findComment-764299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.