/** FUNCTION: generate_ID * * This function generates a random ID of letters and numbers * as long as is desired. * * @ARGUMENTS: 2 * - $np: This determines how many parts are randomly * generated. Some parts will be numbers and * some will be letters. * - $npp: This is the number of pieces-per-part. Each * part is made up of multiple pieces * @RETURNS: * - $id: The randomly Generated ID **/ function generate_ID($np,$npp) { // The id to create $id = ""; // Create an array of characters $aplha = "a b c d e f g h i j k l m n o p q r s t u v w x y z"; $aplha = explode(" ", $aplha); for ($j = 0; $j < $np; $j++) { $r = rand(1,2); for ($i = 0; $i < $npp; $i++) { if ($r == 1) { // Generate random numbers $id .= rand(1,9); } else { // Generate random letters $a = rand(1,26); $id .= $aplha[$a]; } } } return $id; }