fork download
  1. <?php
  2.  
  3. function encontrarValor($domain)
  4. {
  5. if(preg_match('/(http(s)?:\/\/)?(www\.)?(.+)/', $domain, $matches)){
  6. return explode('/',$matches[4])[0];
  7. }
  8. }
  9. echo encontrarValor('https://w...content-available-to-author-only...m.br/url-123');
  10. echo "\n";
  11. echo encontrarValor('https://s...content-available-to-author-only...m.br/url-123');
Success #stdin #stdout 0.02s 23616KB
stdin
Standard input is empty
stdout
site.com.br
site.com.br