get name from url
<p>I have a function to get domain name from url</p>

<pre><code> &lt;?php
 function getdomain($url)
 {
  $explode = explode(".", $url);
  $tld = $explode[1];
  $tld = explode("/", $tld);
  $name = $explode[1];
  print("$tld[0]");
 }

 print(getdomain("aa.namepros.aaa.com/showthread.php?p=350493"));


?&gt;
</code></pre>

<p>It works fine for me, but if a user only entered </p>

<pre><code> print(getdomain("namepros"));
</code></pre>

<p>then, it shows me error. </p>
