Jump to content

Parsing URL for certain strings


imperialized

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.