created on 04 Jun 2008, by Syndication, read more…
A little function which generates random password of a certain length. It uses all letters, both lowercase and uppercase and all numbers.
//generates a random password which contains all letters (both uppercase and lowercase) and all numbers
function generatePassword($length) {
$password='';
for ($i=0;$i $chr='';
switch (mt_rand(1,3)) {
case 1:
$chr=chr(mt_rand(48,57));
break;
case 2:
$chr=chr(mt_rand(65,90));
break;
case 3:
$chr=chr(mt_rand(97,122));