Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

How To Generate a Random Password in PHP

Olivia Rhye

Here's a quick little snippet to generate a random password in php:

function createRandomPassword($length = 7) {
$chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%^&*(){}[]";

$pass = '' ;

while(strlen($pass) <= $length)
{
$pass .= $chars[mt_rand(0, strlen($chars))];
}
return $pass;
}

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy