This is a rewrite of an old name generator as well as an addendum to the old name generator how-to guide here: Moddb.com
<?php
class NameGeneration
{
//$vowel boolean - true for vowel, false for consonant
function randLetter($vowel)
{
$letter = "";
$vowels = array("a", "e", "o", "u");
$consonants = array("b", "c", "d", "v", "g", "t", "l", "f");
switch($vowel)
{
case true:
$letter = $vowels[array_rand($vowels, 1)];
break;
case false:
$letter = $consonants[array_rand($consonants, 1)];
break;
}
return $letter;
}
function generateName()
{
$name = $this->randLetter(false) . "" . $this->randLetter(true) . "" . "" . $this->randLetter(false) . "" . $this->randLetter(true) . "" . $this->randLetter(true) . "";
echo $name;
}
}
$newname = new NameGeneration;
$newname -> generateName();
?>
this rewrite was done by request of a community member who wished an OOP (object oriented programming) version of the script. To note, it seems this name generator is better done in jQuery/JavaScript/PHP combo rather than PHP alone if you are going to make a serious website.
neat!