Regex help

I have coded a system for users to submit their website, if they enter (what they enter -> output): -> -> ->


If they go

It doesn’t strip to

My code:

$url = clean($_POST['url']);
$url = preg_replace("/http:\\/\\//i", "", $url);
$url = preg_replace("/^www\\./i", "", $url);
$url = preg_replace("/\\/.*/i", "", $url);

[fphp]parse_url/fphp and the PHP_URL_HOST option would be a better way to do this me thinks. :wink:

Exactly what I wanted, thanks again :slight_smile: