Skip to content

Instantly share code, notes, and snippets.

@ad3n
Created September 15, 2015 09:53
Show Gist options
  • Save ad3n/749166ba1826a809ebe1 to your computer and use it in GitHub Desktop.
Save ad3n/749166ba1826a809ebe1 to your computer and use it in GitHub Desktop.
<?php
$pwd = '1!';
function checkPassword($pwd, &$errors) {
$errors_init = $errors;
if (strlen($pwd) < 8) {
$errors[] = "Password too short!";
}
if (!preg_match("#[0-9]+#", $pwd)) {
$errors[] = "Password must include at least one number!";
}
if (!preg_match("#[a-zA-Z]+#", $pwd)) {
$errors[] = "Password must include at least one letter!";
}
return ($errors == $errors_init);
}
checkPassword($pwd, $abc);
var_dump($abc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment