web blazonry web development scripts and tutorials Get best price on Samsung Galaxy Note 4, Frosted White 32GB (Verizon Wireless)
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Name Generator Home


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





Generate Your Wu-Name

Created: 1999-11-16

PHP Script to Generate Wu-Name
The PHP script Generate Your Wu-Name generates a random name based of an adjective and a noun an example is my Wu-Name: Drunken Conqueror.

The PHP script uses two plain text files, one that holds all of the adjectives and the other 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.

So next all that is needed is to randomly pick elements from these arrays. However, I don't want this to be totally random because your Wu-Name should not change each time you enter it in. Thus, I'll start the random number generator with a seed number, which will be based on the name entered. Using the PHP function srand(seed_number), which works just likes Perl's function, and generates a random number.

Generating 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;
}

Setting up and Picking from Arrays
Here's 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 another name generator which basically just switches out the adjective files.

Download 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.