siddscool19 Posted October 8, 2008 Share Posted October 8, 2008 I want to get the name of directory say from this url http://www.hii.com/hii/hii/lol.php If I use dirname it will get htdocs all that which i don't want..... So any way to get hii/hii/ ? Link to comment https://forums.phpfreaks.com/topic/127540-solved-get-directory-name/ Share on other sites More sharing options...
waynew Posted October 8, 2008 Share Posted October 8, 2008 echo htmlentities($_SERVER['PHP_SELF']); Link to comment https://forums.phpfreaks.com/topic/127540-solved-get-directory-name/#findComment-659852 Share on other sites More sharing options...
kenrbnsn Posted October 8, 2008 Share Posted October 8, 2008 You want to use a combination of the functions parse_url() and pathinfo() <?php $url = 'http://www.hii.com/hii/hii/lol.php'; $purl = parse_url($url); $pstr = pathinfo($purl['path']); echo $pstr['dirname']; ?> Ken Link to comment https://forums.phpfreaks.com/topic/127540-solved-get-directory-name/#findComment-659870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.