php question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • campimp
    Confirmed User
    • Jan 2007
    • 1340

    #1

    php question

    wanting to store sitename as a php variable.

    if url was www somesitename .com

    i want my page to pull "somesitename" and store as php variable, without the www or the .com

    any thoughts?
  • FlexxAeon
    Confirmed User
    • May 2003
    • 3765

    #2
    where is it pulling 'somesitename' from? from the url it's located at?

    Code:
    <? $somesitename = $_SERVER['SERVER_NAME']; 
    $somesitename = str_replace( 'www.', '', $somesitename);
    $somesitename = str_replace( '.com', '', $somesitename);
    print $somesitename;
    ?>
    flexx [dot] aeon [at] gmail

    Comment

    • cLin
      Registered User
      • May 2009
      • 94

      #3
      Code:
      $domain_strip = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']);
      $domain = substr($domain_strip, 0, strpos($domain_strip, "."));
      Grabs the domain name from website url. If that's what you want.
      Chris
      The Ex Girlfriend Pics

      Comment

      • quantum-x
        Confirmed User
        • Feb 2002
        • 6863

        #4
        Originally posted by cLin
        Code:
        $domain_strip = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']);
        $domain = substr($domain_strip, 0, strpos($domain_strip, "."));
        Grabs the domain name from website url. If that's what you want.
        Erk.
        Try:
        Code:
        echo parse_url($u,PHP_URL_HOST);
        Where $u has your URL string.
        PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

        Comment

        • daniel_webcams
          Confirmed User
          • Nov 2008
          • 2491

          #5
          Originally posted by FlexxAeon
          where is it pulling 'somesitename' from? from the url it's located at?

          Code:
          <? $somesitename = $_SERVER['SERVER_NAME']; 
          $somesitename = str_replace( 'www.', '', $somesitename);
          $somesitename = str_replace( '.com', '', $somesitename);
          print $somesitename;
          ?>
          Daniel,

          Skype: [email protected]
          ICQ: 354-220-339
          Email: daniel@adultforce[dot]com


          Comment

          Working...