title: Getting domain name without TLD
body: <p>I have this code right here:</p>
  
  <pre><code>    // get host name from URL
      preg_match('@^(?:http://)?([^/]+)@i',
      "http://www.joomla.subdomain.php.net/index.html", $matches);
      $host = $matches[1];
  
      // get last two segments of host name
      preg_match('/[^.]+\.[^.]+$/', $host, $matches);
      echo "domain name is: {$matches[0]}\n";
  </code></pre>
  
  <p>The output will be <code>php.net</code></p>
  
  <p>I need just <code>php</code> without <code>.net</code></p>