web blazonry web development scripts and tutorials Get best price on Unlocked Galaxy S20 5G
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Name Generator Home


Name Generators
  Wu-Name
  U.S. Name
  Baby Name





Wu-Name Name Generator - How It Works

Wu-Name Name Generator creates a random name consisting of an adjective and a noun. For example, my Wu-Name is Drunken Conqueror.

The PHP script uses two plain text files. One file holds all the adjectives. The other consists of all of the nouns. The script reads these files into two arrays. The PHP function file(filename) reads the filename file into an array with each line being an element of the array.

Next, randomly pick an element from each array. However, I don't want this to be totally random because your Wu-Name should not change each time you enter generate it. Thus, I start the random number generator with a seed number, which is based on the name entered. I use the PHP function srand(seed_number) to generate a random number. (This works just like the Perl function.)

How to Generate the Seed Number
To generate the seed number, I take the name submitted and character by character convert it to its ASCII number, using the PHP function ord(chr). This would generate the same name for ab as it would ba, so to avoid that I multiply the ASCII number by its position in the name.

$seed = 0; $s=0; for ($e=1; $e<=$len; $e++) {
$chr = substr($realname,$s,$e);
$seed = $seed + ord($chr)*$e;

$s=$e;
}

How to Set Up and Pick from Arrays
Here is the PHP code for setting up the two arrays and creating the random number:

// set up arrays
$adj_array = file("adjs");
$noun_array = file("nouns");

// start random number with seed
srand($seed);

// get random numbers
$arnd = rand(0,sizeof($adj_array)-1);
$nrnd = rand(0,sizeof($noun_array)-1);

// create name from names and arrays
$wuname = "$adj_array[$arnd] $noun_array[$nrnd]";

 

U.S. Name Generator is based on wu-name name generator script. It basically switches out the adjective files for files consisting of first name and last name and uses a more complex form by adding a drop-down menu to select male or female.

Baby Name Generator is another name generator is based on wu-name name generator script. It switches out the adjective files for files consisting of first name and middle name and uses a more complex form by adding a drop-down menu to select boy or girl.

Get the full script here (wuname.phps)
View Adjective File
View Nouns File

 

Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.