PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 26: Write a PHP program to generate simple random password [do not use rand() function] from a given string.

random_password.php

<!DOCTYPE html>
<html>
<head>
	<title>PHP Progarms TutorialDuniya.com</title>
</head>
<body>
	<?php
		function password_generate($chars)
		{
			$data = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
			return substr(str_shuffle($data), 0, $chars) ;
		} 

		echo password_generate(7) . "\n";
	?>
</body>
</html>


If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.