title: PHP Check if URL is a subdomain URL or not
body: <p>I wrote a function to validate if the given URL is a sub-domain URL or not.</p>
  
  <pre><code>&lt;?php
  
  header("Content-Type: text/plain"); 
  
  function isSubDomain($myDomain)
  {
  
      $myDomain=parse_url($myDomain)["host"];
  
      if(strstr($myDomain,'.',true)=='www')
      {
          return 0;
          break;
      }
  
      $domainExtentions=array(
                              '.com',
                              '.net',
                              '.org',
                              '.co.uk'
                              );
  
      foreach($domainExtentions as $extention)
      {
          if($extention==substr($myDomain,-(strlen($extention))))
          {
              $mydomain=substr($myDomain,0,-(strlen($extention)));
          }
  
      }
  
      if (substr_count($mydomain,'.')&gt;0)
      {
          return 1;
      }
  
  }
  
  //Sub-domain exists
      if(isSubDomain('http://SUBDOMAIN.hezi-gangina.com/pua/pug/index.php?q=balataLeStus'))
      {
          echo'This url contains sub-domain!';
          echo "\r\n";
      }
      else
      {
          echo'This url doesn\'t have any sub-domain!';
          echo "\r\n";
      }
  
  //No subdomain (www)    
      if(isSubDomain('http://www.hezi-gangina.com/pua/pug/index.php?q=haMetrixHeshbon'))
      {
          echo'This url contains sub-domain!';
          echo "\r\n";
      }
      else
      {
          echo'This url doesn\'t have any sub-domain!';
          echo "\r\n";
      }
  
  //Non www url (and no sub-domain)
      if(isSubDomain('http://hezi-gangina.com/pua/pug/index.php?q=einLehaSikuy'))
      {
          echo'This url contains sub-domain!';
          echo "\r\n";
      }
      else
      {
          echo'This url doesn\'t have any sub-domain!';
          echo "\r\n";
      }
  </code></pre>
  
  <p>Looks like working perfectly (and off-course the domain extensions should be fully updated) and that brings the question...</p>
  
  <ol>
  <li><p>Is there any "right outside the box" PHP command that store an array with all domain extensions or do I need to update it manually?</p></li>
  <li><p>AFTER removing all possible extensions from any given URL <strong>AND</strong> the domain is not starting with www... Is it possible that it won't be a sub-domain?</p></li>
  </ol>