Home > PHP > PHP Password Generator

PHP Password Generator

Here is a function that will generate a string of random characters, ideal if you want to create a password for a new user.

function generatePassword($length=10){
 $pass = '';
 $parts = array_merge(range(0,9),range('a','z'),range('A','Z'));
 for($i=0;strlen($pass)<=$length;$i++){
  $pass .= $parts[array_rand($parts)];
 }
 return $pass;
}

Use the function like this.
echo generatePassword();

To create a longer password string just pass a parameter with the function.
echo generatePassword(5);

Information, services, and products:
We sell Diesel Generator
Rangemaster Range Cookers at great prices.
stair parts at great prices.
Cookers at great prices.
vendita pneumatici
Categories: PHP Tags: , , , ,