PHP guys please fix this shit for me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. Mike
    Confirmed User
    • Aug 2004
    • 913

    #1

    PHP guys please fix this shit for me

    PHP Code:
    $full_url = "http:///www.wojfun.com/contactus_form.html";
    $pos_dslash = strpos($full_url, "/", 7);
    $trimmed_url = substr($full_url, 0, $pos_dslash); 
    
    trimmed url= http://www.wojfun.com

    Please fix this so result is only www.wojfun.com (without http://)

    thanks!!!
    Sig for sale. ICQ: 163-545-054
  • webgeek
    Confirmed User
    • Mar 2007
    • 165

    #2
    check http://php.net/parse_url
    webgeek

    Comment

    • SmokeyTheBear
      ►SouthOfHeaven
      • Jun 2004
      • 28609

      #3
      $url = "http://www.site.com/blah/etc.com";
      // remove the http://
      $url = str_replace("http://","",$url);
      // split at "/"
      $exp = explode("/",$url);
      // result is everything before first /
      $end = $exp[0];

      theres shorter ways but to show whats going on
      hatisblack at yahoo.com

      Comment

      • BigBen
        Confirmed User
        • Nov 2004
        • 2299

        #4
        Edit - Nevermind.

        Comment

        • SmokeyTheBear
          ►SouthOfHeaven
          • Jun 2004
          • 28609

          #5
          or you could just add this to the code you have ( last line )
          $trimmed_url = str_replace("http://","",$trimmed_url);
          hatisblack at yahoo.com

          Comment

          • Mr. Mike
            Confirmed User
            • Aug 2004
            • 913

            #6
            Originally posted by SmokeyTheBear
            $url = "http://www.site.com/blah/etc.com";
            // remove the http://
            $url = str_replace("http://","",$url);
            // split at "/"
            $exp = explode("/",$url);
            // result is everything before first /
            $end = $exp[0];

            theres shorter ways but to show whats going on
            Perfect, thank you!!
            Sig for sale. ICQ: 163-545-054

            Comment

            • SmokeyTheBear
              ►SouthOfHeaven
              • Jun 2004
              • 28609

              #7
              if you do it this way then the url can either have http:// or not it wont matter
              hatisblack at yahoo.com

              Comment

              • Mr. Mike
                Confirmed User
                • Aug 2004
                • 913

                #8
                Originally posted by SmokeyTheBear
                if you do it this way then the url can either have http:// or not it wont matter
                yeah the urls are all in a db, they all have http://, your code worked perfect.
                Sig for sale. ICQ: 163-545-054

                Comment

                • Bro Media - BANNED FOR LIFE
                  MOBILE PORN: IMOBILEPORN
                  • Jan 2004
                  • 16502

                  #9
                  preg_match('!^https?://([a-zA-Z\-_\.0-9]+)!',addslashes(htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES)), $ref);

                  $ref[1] result in www.referringsite.com

                  Comment

                  • Alky
                    Confirmed User
                    • Apr 2002
                    • 5651

                    #10
                    Originally posted by webgeek
                    another bump for people trying to reinvent the wheel

                    Comment

                    • SmokeyTheBear
                      ►SouthOfHeaven
                      • Jun 2004
                      • 28609

                      #11
                      Originally posted by Alky
                      another bump for people trying to reinvent the wheel
                      no harm in that , people have made billions over the years reinventing the wheel over and over..
                      hatisblack at yahoo.com

                      Comment

                      • tommy gun
                        Registered User
                        • Apr 2007
                        • 13

                        #12
                        I like the perl version:

                        Code:
                        print "please paypal $100";
                        my $deposit = <STDIN>;
                        if ($deposit == 100) {
                            do_work();
                        }
                        Last edited by tommy gun; 04-01-2007, 10:37 PM.

                        Comment

                        • Alky
                          Confirmed User
                          • Apr 2002
                          • 5651

                          #13
                          Originally posted by SmokeyTheBear
                          no harm in that , people have made billions over the years reinventing the wheel over and over..
                          rewriting a function which uses more system resources can make millions?

                          Comment

                          • V_RocKs
                            Damn Right I Kiss Ass!
                            • Nov 2003
                            • 32451

                            #14
                            Code:
                            $full_url = "http:///www.wojfun.com/contactus_form.html";
                            $trimmed_url = str_replace("http://","",$full_url);

                            Comment

                            • tommy gun
                              Registered User
                              • Apr 2007
                              • 13

                              #15
                              Code:
                              $trimmed_url = preg_replace('/^http:\/\/:/', '', $full_url);
                              $trimmed_url = preg_replace('/\/.*/', '', $trimmed_url);

                              Comment

                              Working...