Create Four 4 Letter Domain Name, Password, Key Combination PHP Array Script

Couple of days ago I wrote a script to check all available 3 letter domain names unfortunately there aren’t any:) Then I said why not check 4 letter domain names. My 3 letter domain script did not work for 4 letters. There are 26 times more combination so I decided to check letter by letter. I created a PHP script that creates an array for every letter combination. I wanted to share it with you. You might find it useful, here is the script.

<?php
$number = $_GET['num'];
if(!preg_match('/^[0-9]+$/', $number, $maches) || $number > 25)
	exit;
//create the letter array
$list = range('a', 'z');
$domain_list = '';

foreach($list as $i2)
{
	foreach($list as $i3)
	{
		foreach($list as $i4)
			$domain_list .= "'".$list[$number].$i2.$i3.$i4."', ";
	}
}
//take out the comma at the end
$domain_list = rtrim($domain_list, ', ');
$domain_list = '<?php $domain_list = array('.$domain_list;
$domain_list .= '); ?>';
echo htmlspecialchars($domain_list);//when you call the script it will output the data to see everything worked or not.

//write the array into a PHP file
if($handle = @fopen('lists/list'.($number+1).'.php', 'w'))
{
	fwrite($handle, $domain_list);
	@fclose($handle);
}
?>

Let me explain the script a little. Name the script whatever you like. Say you named it create_list.php when you are calling the script you will have to call it with a GET param ex: create_list.php?num=0
You are going to have to do this for every letter from A to Z (0-25) Every letter array will be written into a PHP file under lists directory. If you want to change the file structure change it in the script. When you are done writing all the arrays simply include needed array(s) in you files.
Ex: For the letter “A” combination

include_once('lists/list1.php');

Hope you liked Create Four 4 Letter Domain Name, Password, Key Combination PHP Array Script. Please feel free to ask questions or leave a comment.

Thank you for visiting.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.