Has anyone created a random name generator in PHP? I’m currently looking into creating a music game as a project in php and ideally I would like to create band names and song names randomly. I have looked through here and google but can’t quite seem to find anything. Anyone seen something that can do this or something similar? I understand that a random string might not make sense so I would need a little control over what types of words are generated. I’ve seen many name generator sites and such so I know it’s possible but I want to create my own script…
This should get you started.
// PHP 5.4+ syntax $names = ['Ann','Bill','Cory']; shuffle($names); $name = array_pop($names);
Thanks, that’s a great start. But what if I wanted to create a band name something like ‘The Black Giraffe’? Would it be that I set up a number of arrays each with a specific type of word in each, such as an array containing ‘The This Is’ and another with perhaps colours and then maybe say animals so as a result could be ‘The Brown Dog’? Not a name I really want but you get the idea… I suppose with move variables I got to watch that it makes sense.
You can try to use something like: https://github.com/fzaninotto/Faker which will greatly save your time.
Thanks, I will take a look at this.
What you describe here is very close to how I implemented BusinessSpew. My implementation is in Ruby (on Rails) but the principle should be easy to apply.
The individual “parts of speech” are listed here. Within each group there is a random one chosen and then they are concatenated into sentences.
Thanks, will look at what you’ve done and try to adapt it for my needs.