DeveloperBreeze

Snippets Programming Tutorials, Guides & Best Practices

Explore 196+ expertly crafted snippets tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

PHP Generate Random Password

Code January 26, 2024
php

// Define the set of characters for the password
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*';

// Generate a random password by shuffling the characters and selecting the first 12
$password = substr(str_shuffle($characters), 0, 12);

// Display the generated password
echo 'Random Password:', $password;