title: Get email domain name without name before @ and tld
body: <p>I need to get just the domain name from an email address - so if the email address is john@gmail.com I need to grab just the gmail part.  </p>
  
  <p>I have the following code that works and returns <strong>gmail</strong> for a john@gmail.com email address but returns <strong>co</strong> for a john@gmail.co.uk email address.</p>
  
  <pre><code>$user_register_email = "john@gmail.co.uk";
  
  $domain = preg_replace( '!^.+?@(.+?)$!', '$1', $user_register_email );
  $domain = explode('.', $domain);
  $domain = array_reverse($domain);
  $domain = "$domain[1]";
  
  echo $domain;
  </code></pre>
  
  <p>Can anyone tell me how I amend the above code so it will also work for gmail.co.uk addresses please?</p>
  
  <p>Many thanks,</p>
  
  <p>John</p>