note 53197 deleted from function.rand by felipe

From: Date: Sun, 30 Dec 2007 18:43:14 +0000
Subject: note 53197 deleted from function.rand by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134419@lists.php.net to get a copy of this message
Note Submitter: cmol at cmol dot dk ---- Made this random keygen function. It's totally random.. And you can set the number of characters as you use it... <?php function keygen($max){ $items = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $x = 1; $total = strlen($items) - 1; while($x <= $max){ $rand = rand(0, $total); $item = substr($items, $rand, 1); if($x == 1){ $key = $item; } elseif($x > 1) { $key .= $item; } $x++; } echo $key; } $number = 10; echo keygen($number); ?> You can change the "items" as you like...

« previous php.notes (#134419) next »