How do I remove the URL protocol and slash from user input in PHP

ereg_replace is now deprecated, so it is better to use:

$url = preg_replace("(^https?://)", "", $url );

This removes either http:// or https://

Leave a Comment