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 Quote 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. Quote 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" Quote 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!! Quote Link to comment https://forums.phpfreaks.com/topic/145579-getting-previous-directory-name/#findComment-764299 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.