What I am trying to do is the following:
I am trying to validate a password, the password must have at least two uppercase, two lowercase, two numbers and minimum 8 characters.
For this I am trying to use a regular expression which is the following:
$uppercase = preg_match('#[A-Z]#', $password);
$lowercase = preg_match('#[a-z]#', $password);
$number = preg_match('#[0-9]#', $password);
$special = preg_match('#[#[W]{2,}#', $password);
$length = strlen($password) >= 8;
if(!$uppercase || !$lowercase || !$number || !$special || !$length) {
$errorpw = 'Bad Password';
But this only validates 1 number, 1 uppercase and 1 lowercase. The order in which these data are written can be any, it doesn't have to be a specific order like for example ASdf12, it can be mixed example AsDf12