Previous Article

PHP function to generate a random password

Next Article

This simple function generates a random password using all alphanumeric characters. While this won't be the most secure password, it is better than a dictionary word. The function accepts an integer to determine the password length, but if one isn't passed defaults to 16.

function password_generator($length = 16)
    $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for ($i = 0, $password = ''; $i < $length; $i++) {
        $password .= substr($str, mt_rand(0, strlen($str) - 1), 1);
    return $password;
Avatar of Clive Walkden

Clive Walkden

Latest Articles


Output All Users Cron Jobs

If you want to check all users cron jobs this little command will output them to the command line

Magento 2

Magento 2 admin password history reset

Do you want to clear the password history on your staging test site (not recommended for live)?


How to see files changed on a certain date

As a sysadmin you often need to see which files have been modified on a certain date.