$re = '/matei 170 associative arrays/m';
$str = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Community Login</title>
</head>
<body>
<h2>Community Login</h2>
<form method="post">
<label for="username">Username:</label>
<input type="text" name="username" id="username"><br><br>
<label for="password">Password:</label>
<input type="password" name="password" id="password"><br><br>
<button type="submit" name="login">Login</button>
</form>
<?php
$communityUsers = [
"GAM" => password_hash("gamgamstyle", PASSWORD_ARGON2ID),
"MAO" => password_hash("gentoo", PASSWORD_ARGON2ID),
"MaxiObe" => password_hash("iloveallmias", PASSWORD_ARGON2ID)
];
if (isset($_POST[\'login\'])) {
$enteredUsername = $_POST[\'username\'];
$enteredPassword = $_POST[\'password\'];
if (!empty($enteredUsername) && !empty($enteredPassword)) {
if (array_key_exists($enteredUsername, $communityUsers)) {
if (password_verify($enteredPassword, $communityUsers[$enteredUsername])) {
echo "<p style=\'color:green;\'>Login successful! Welcome, " . htmlspecialchars($enteredUsername) . " </p>";
} else {
echo "<p style=\'color:red;\'>Incorrect password.</p>";
}
} else {
echo "<p style=\'color:red;\'>Username not found.</p>";
}
} else {
echo "<p style=\'color:red;\'>Please fill in both fields!</p>";
}
}
?>
</body>
</html>
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php