Q:

Write a PHP script to generate simple random password [do not use rand() function] from a given string

0

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

Sample string : '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz'
Note : Password length may be 6, 7, 8 etc

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function password_generate($chars) 
{
  $data = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz';
  return substr(str_shuffle($data), 0, $chars);
}
  echo password_generate(7)."\n";
?>

Sample Output:

89Qp3AK

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now