Last active
September 7, 2017 18:54
-
-
Save Haolicopter/34be48b9694956e30540a1bdf52f7e20 to your computer and use it in GitHub Desktop.
Generate random domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dict = file('basicWords'); | |
$file = 'domains.txt'; | |
$numOfDomains = 300; | |
$content = ''; | |
for ($i=0; $i < $numOfDomains; $i++) { | |
$content .= generateRandomDomain($dict) . "\n"; | |
} | |
file_put_contents($file, $content); | |
function generateRandomDomain($dict, $numOfWords = 3, $glue = '-'){ | |
$words = []; | |
for ($i = 0; $i < $numOfWords; $i++) { | |
$newWord = trim($dict[rand(1, count($dict))]) ?: 'empty'; | |
$words[] = strtolower($newWord); | |
} | |
return implode($glue, $words) . ".com"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment