[Solved] generate password and specify how many degints and words [closed]


Guessing you might benefit from an answer that walked you through what was going on, rather than just giving you wanted, might be useful for you in the future.

function randomString($length) { // Generates a random string of $length characters long
    $letters = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ"; // Characters you don't mind having more than one of
    $random_string = '';
    for ($i = 0; $i < $length; $i++) { // Until $i = $length, do the following & increment $i by 1 each time
        $random_string .= $letters[rand(0, (strlen($letters) - 1))]; // Add another random character to the string
    }
    $random_string[rand(0, ($length - 1))] = rand(0,9); // Replace one of the characters with a random number between 0 and 9

    return $random_string;
}

echo randomString(15);

3

solved generate password and specify how many degints and words [closed]