note 53197 deleted from function.rand by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.