NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Get domain type (LLL, NNN, 3 letter .com etc) - Nicely commented

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 10-23-2007, 03:51 AM THREAD STARTER               #1 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund

Get domain type (LLL, NNN, 3 letter .com etc) - Nicely commented


Enjoy, I could've done switches where I used the 2 elseif's, but I felt more confident this way.

PHP Code:
<?php 

   
/*                   Danltn               */
   /* Free to use if this message stays here */
   /*             http://danltn.com          */


$domain $_GET['domain']; // No explaination needed
if(!$domain) { $domain "lol-101.com"; } // This was just for testing purposes, feel free to remove it
$original $domain// Lets keep a copy incase we want it later
$domain strtolower($domain); // Make all the letters the same, although we will use insensitive functions, it might help
$domain explode(".",trim($domain)); // Let's get all the parts of the domain
$root trim($domain[0]); // Let's get the beginning of the domain

$chars preg_split('//'$root, -1PREG_SPLIT_NO_EMPTY); // PHP 4 + 5 version
$len strlen($root); // Get it's length

foreach($chars as $none => $letter) { // We'll start a foreach loop, where we will compare each letter with an ereg string

if (eregi('[a-z]'$letter)) { // a-z insensitive check
$list[] = "l"// Return L
}
elseif (
eregi('[0-9]'$letter)) { // 0-9 check
$list[] = "n"// If true, return N
}
elseif (
$letter == "-") { // See if it's just a dash
$list[] = "-"// If it is, return a dash
}
else { 
// We don't know what it is
$list[] = "?"// Return a question mark
}
}

$root strtoupper(implode("",$list)); // Put it together again, make it UPPERCASE.
$ext strtolower(implode(".",$domain)); // I can't remember if it's caps or not, we'll just lower it to be safe
$ext str_replace($domain[0],"",$ext); // Remove the actual domain, just leave the extension

for($i 0$i strlen($root); $i++) { 
$n .= "N"// This was the easiest way I think to generate a string x characters long, please PM me if there's a better way
$l .= "L"// Same for Letters
}

switch (
$root) { // Let's play with the $root
case $l// If it's an LLL...
 
$type "letter"// It's a letter
 
break; // Good, that'll do. Stop.
case $n// If it's an NNN...
 
$type "number"// It's a number
 
break; // If it's satisified, we'll stop
default: // It's neither a number or a letter, it must be a character
????: NamePros.com http://www.namepros.com/code/387651-get-domain-type-lll-nnn-3-a.html
 
$type "character"// So we'll call it just that
}

echo 
"<code>$original</code> is a <code>$root$ext</code> ($len $type $ext)"// Tell them
????: NamePros.com http://www.namepros.com/showthread.php?t=387651

?>
Daniel is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:14 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger