Random name generator

Status
Not open for further replies.

nis

New member
Mar 4, 2007
357
4
0
Need a butload of random names? Maybe for authors for your splog-network? Look no further!

In my infinite wisdom I have created a magical file that will spit out more random names than you can shake a stick at (Oh, I love that expression).

As a special perk for you WF'ers I included the gendermatic subroutine, so you will now what gender that random name that just landed in your lap, is.

Now, enough lofty talk. Its just a small php-function with 1000 male firstnames, 1000 female ditto and 1000 lastnames. It will make you a random name with a gender of your choise, or a random gender (100 points to you if you get a gender other than male or female ;) ).

Here is the function doing all the work:

Code:
	function makename($gender, $rand = 0)
	{
		// Get the names
		global $malefirstnames;
		global $femalefirstnames;
		global $lastnames;
		
		if ($rand) { //Should the name be a random gender?
			return makename(rand(0, 1)); // Indeed.
		} else {
			if ($gender) { // Lets make us a male name.
				$name['gender'] = 'Male';
				$name['firstname'] = $malefirstnames[rand(0, (count($malefirstnames) - 1))];
			} else { // Ditto female.
				$name['gender'] = 'Female';
				$name['firstname'] = $femalefirstnames[rand(0, (count($femalefirstnames) - 1))];
			}
			$name['lastname'] = $lastnames[rand(0, (count($lastnames) - 1))];
			return $name;
		}
	}

I didn't include all the names, but they are in the attached file.

Use it like this:

Code:
makename(1); // Returns a male name
makename(0); // Returns a female name
makename(1, true); // Returns a name of random gender

The output looks like this:

Code:
Array
(
    [gender] => Female
    [firstname] => Jewell
    [lastname] => Cohen
)

Thats about it. Go make some names.
 

Attachments

  • random-name-generator.php.zip
    11.3 KB · Views: 12


Dammit! I was so close to make my 100th post something of value. Now its just this filler add-on comment :(
Oh, well. Thats life for you.
 
Yeah, now I can give more names to my sims than just naming them Jack, Jane, Jack, Jack jr., Jack the 2nd, Jane the trailercampwhore...
 
Status
Not open for further replies.