imperialized Posted November 16, 2014 Share Posted November 16, 2014 Hey guys!! So basically what I am doing here is pulling the directory out of a url.URL ex: http://www.xxx.com/THIS_IS_WHAT_I_WANT/ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $arr = explode("/", $actual_link, 5); $page = $arr['3']; if($page <> ""){ $curPage = $page; }else{ //Home Page $curPage = "home"; } The code works as is. Being that I prefer to code the proper way and learn new things; is this the best way? Quote Link to comment https://forums.phpfreaks.com/topic/292509-parsing-url-for-certain-strings/ Share on other sites More sharing options...
Barand Posted November 16, 2014 Share Posted November 16, 2014 Have you looked at http://php.net/manual/en/function.parse-url.php Quote Link to comment https://forums.phpfreaks.com/topic/292509-parsing-url-for-certain-strings/#findComment-1496770 Share on other sites More sharing options...
requinix Posted November 17, 2014 Share Posted November 17, 2014 Current URL? Is this always running for a file that's in a subdirectory and not like /file.php? dirname($_SERVER["REQUEST_URI"]) Quote Link to comment https://forums.phpfreaks.com/topic/292509-parsing-url-for-certain-strings/#findComment-1496772 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.