Parsing Current URL for Base Name-PHP

Discussion in 'Programming' started by jakob, Nov 20, 2008.

  1. #1
    What I need to do is have a little php script "read" the current URL and parse out the base domain name (without tld) so I can use this in a page or article as a variable. For example, if the url is www.domain1.US/articles/vehicles/trucks.htm the script will find "domain1."

    What would be even better is if the script could read the current page URL, parse out the base name, compare it to a mysql table and automatically return another field

    domain1 | cars
    domain2 | trucks
    domain3 | motorcycles

    Would this be possible? I would appreciate any insight.
     
    jakob, Nov 20, 2008 IP
  2. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hmm, try and look at the $_SERVER['HTTP_HOST'] variable and take it from there :)
     
    shineDarkly, Nov 20, 2008 IP