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? 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 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"]) 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
Archived
This topic is now archived and is closed to further replies.