Re: Re: get domain component from email
| From: | Jim Lucas | Date: | Tue, 07 Aug 2007 21:46:58 +0000 |
| Subject: | Re: Re: get domain component from email | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260339@lists.php.net to get a copy of this message | ||
Stut wrote:
Jim Lucas wrote:Are all domains that use ccTLD's created/formatted like other not ccTLD's just with the .uk or whatever tagged on the end? Something like this your example stut.co.uk is this the base for your domain. Basically, would this be stut.com if it were a dot.com ?? or would it be something like... stut.getyourfreesubdomains.com ?? I guess, this is my question. When you registered that domain. you registered stut.co.uk, right? or was it something else? -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William ShakespeareStut wrote:Indeed, your "fixed" version converts stut.co.uk (whose owner I periodically curse) to co.uk. Which brings me back to my earlier question of why would you want to do this? I can't think of any reason, but then again it is getting late. -Stut Question for you then.Jim Lucas wrote:ok, too quick on the draw there. one would have to be able to run a whois look up on the output to see if it fails or succeeds to be able to get the final verdict, but it would get you most of the way there. :)Dan wrote:And yours is fatally flawed. Not all ccTLDs are sub-divided.What are you trying to do exactly, maybe there's a better way. If you're trying to determine if an email address is valid there's a pretty cool way to do so by using dns records. It's like 5 lines, here's the site http://www.sitepoint.com/article/users-email-address-php As far as actually just getting the domain, w/o subdomains from a string you could try this. I'm not sure if the code runs because I haven't tested it, and I have been working exclusively with Delphi for a month so something might be off. function getDomain($email) { list($userName, $mailDomain) = split("@", $email); $anarray = split(".", $mailDomain); for ($i = 0; $i < count($anarray); $i++) { if (in_array($anarray[$i], $TLDArray)) // if $anarray[$i] is a TDL then we move back 1 to get it's domainAs far as I can tell, this doesn't work at all. Yours, http://www.cmsws.com/examples/php/domain_verification/example2.php Mine, http://www.cmsws.com/examples/php/domain_verification/example.phpreturn $anarray[$i-1] . '.' . $anarray[$i];} }