Write a PHP script to generate simple random password from a given string
str_shuffle():-
The str_shuffle() function randomly shuffles all the characters of a string.
substr():-The substr() function returns a part of a string.
code:-
<?php
function password_generate($char)
{
$data = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz';
return substr(str_shuffle($data), 0, $char);
}
echo password_generate(10)."\n";
?>
output:-
hdbvch8772
Post a Comment
If you have any doubts, Please let me know
Thanks!