Trim a url to just the domain name using PHP
<p>I have a database table column that stores urls of a persons website. This column is unique as I don't want people using the same website twice!</p>

<p>However a person could get around this by doing:</p>

<pre><code>domain.com
domain.com/hello123
www.domain.com
</code></pre>

<p>So my plan is to make it so that when a person saves their record it will remove everything after the first slash to make sure only the domain is saved into the database.</p>

<p>How would I do this though? I'm presuming this has been done lots of times before, but I'm looking for something VERY VERY simple and not interested in using libraries or other long code snippets. Just something that strips out the rest and keeps just the domain name.</p>
