GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP guys please fix this shit for me (https://gfy.com/showthread.php?t=720277)

Mr. Mike 04-01-2007 09:31 PM

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_url0$pos_dslash); 

trimmed url= http://www.wojfun.com

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

thanks!!!

webgeek 04-01-2007 09:34 PM

check http://php.net/parse_url

SmokeyTheBear 04-01-2007 09:35 PM

$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

BigBen 04-01-2007 09:35 PM

Edit - Nevermind.

SmokeyTheBear 04-01-2007 09:38 PM

or you could just add this to the code you have ( last line )
$trimmed_url = str_replace("http://","",$trimmed_url);

Mr. Mike 04-01-2007 09:39 PM

Quote:

Originally Posted by SmokeyTheBear (Post 12180195)
$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!!

SmokeyTheBear 04-01-2007 09:41 PM

if you do it this way then the url can either have http:// or not it wont matter

Mr. Mike 04-01-2007 09:43 PM

Quote:

Originally Posted by SmokeyTheBear (Post 12180217)
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.

Bro Media - BANNED FOR LIFE 04-01-2007 09:43 PM

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

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

Alky 04-01-2007 10:20 PM

Quote:

Originally Posted by webgeek (Post 12180191)

another bump for people trying to reinvent the wheel

SmokeyTheBear 04-01-2007 11:24 PM

Quote:

Originally Posted by Alky (Post 12180314)
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..

tommy gun 04-01-2007 11:36 PM

I like the perl version:

Code:

print "please paypal $100";
my $deposit = <STDIN>;
if ($deposit == 100) {
    do_work();
}


Alky 04-01-2007 11:42 PM

Quote:

Originally Posted by SmokeyTheBear (Post 12180487)
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? :winkwink:

V_RocKs 04-01-2007 11:52 PM

Code:

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


tommy gun 04-02-2007 12:08 AM

Code:

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



All times are GMT -7. The time now is 06:17 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123