How to chop website name from url?
<p>I would like to get website name from url</p>

<p>for example</p>

<ul>
<li><p>from <code>http://www.bbc.co.uk/news/</code> i want to get bbc</p></li>
<li><p>from <code>http://security.blogs.cnn.com/2011/11/20/greatest-challenges-to-fighting-terror/?hpt=hp_t1</code> i want to get  cnn.com</p></li>
</ul>

<p>I did write a code like this but doesn't seem to work in different circumstances</p>

<pre><code>$name = substr($url, strpos($url, '/') +2 , strpos($url, '.')-3);
</code></pre>
