How to fetch Domain names from Urls in MySql

Discussion in 'PHP' started by FutureKing, Sep 3, 2012.

  1. #1
    Solved! View solution.
    FutureKing, Sep 3, 2012 IP
  2. #2
    If you want to do it through MYSQL
    
    SELECT SUBSTRING_INDEX(REPLACE(REPLACE(url, "http://", ""), "www.", ""), '/', 1);
    Code (markup):
    If you want to do it through PHP
    $parsed = parse_url($url);
    $domain = $parsed['hostname'];
    
    PHP:
     
    Gemba, Sep 3, 2012 IP
  3. FutureKing

    FutureKing Well-Known Member

    Messages:
    194
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    4
    #3
    Thanks a lot!
    Great! :) :)
     
    FutureKing, Sep 3, 2012 IP
  4. FutureKing

    FutureKing Well-Known Member

    Messages:
    194
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    4
    #4
    Thanks a lot!
    Great! :) :)
     
    FutureKing, Sep 3, 2012 IP