#native_company# #native_desc#
#native_cta#

QUICK random string generator

By Paul Appleyard
on July 10, 2002

Version: 1.0

Type: Function

Category: Algorithms

License: GNU General Public License

Description: function that returns password of length n containing alphanumeric characters (A-z, a-z, 0-9)

function getPass($length=8)
{
$code = "";
$arr = array();

// Generate 62 element array with all posiible chars
$arr = array_merge(range(0,9),range('a','z'),range('A','Z'));

// srand not needed for php 4.2.0 and up
srand ((float) microtime() * 10000000);

foreach (range(1,$length) as $tmp) {
    $code .= $arr[rand(0,61)];
}
return $pass;
}