brightwood
asked on
Substract from a string
I using $_SERVER['HTTP_REFERER'] to get the referals to my site.
And I get them as
http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395
I would like to store them as
http://www.dunemaul.org
http://www.fallenheroes-guild.com
http://www.gwi.dk
But I need help to how substract this.
And I get them as
http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395
I would like to store them as
http://www.dunemaul.org
http://www.fallenheroes-guild.com
http://www.gwi.dk
But I need help to how substract this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If it's a whole list or URL's you have to parse, you can use this:
<?php
$s = 'http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395';
preg_match_all('/.*?\/\/[^ \/]+/', $s, $matches);
print_r($matches);
?>
<?php
$s = 'http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395';
preg_match_all('/.*?\/\/[^
print_r($matches);
?>
http://in.php.net/manual/en/function.parse-url.php