Link to home
Start Free TrialLog in
Avatar of brightwood
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.
ASKER CERTIFIED SOLUTION
Avatar of Robin Hickmott
Robin Hickmott

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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);

?>