What are the potential security risks of storing multiple passwords in an array in PHP?
Storing multiple passwords in an array in PHP can pose a security risk because if the array is compromised, all passwords can be easily accessed by an attacker. To mitigate this risk, it is recommended to use a secure password hashing algorithm like bcrypt to securely store passwords in a database rather than in an array.
// Example of securely storing passwords in a database using bcrypt hashing
// Password to be stored
$password = "mySecurePassword123";
// Hash the password using bcrypt
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);
// Store the hashed password in the database
// INSERT INTO users (username, password) VALUES ('myUsername', '$hashedPassword');