PHP generate password

09.Jul.2010

Have you ever wondered how to generate password in PHP? With PHP generate password function it can be really easy task. You just need to send the length of generated password, od add/remove some characters from $password variable.

1
2
3
4
5
function generate_password($length) {
	$password = str_shuffle('[email protected]#$%^&*()_+;[]/.,<>');
	//return generated password
	return substr($password , -$length);
}