<?php function validatePassword($pwd) { $messages = []; if (strlen($pwd) < 8) { $messages []= "Your Password Must Contain At Least 8 Characters!"; } if (strlen($pwd) > 16) { $messages []= "Your Password is too long!"; } if(!preg_match("#[0-9]+#", $pwd)) { $messages []= "Your Password Must Contain At Least 1 Number!"; } if(!preg_match("#[A-Z]+#", $pwd)) { $messages []= "Your Password Must Contain At Least 1 Capital Letter!"; } if(!preg_match("#[a-z]+#", $pwd)) { $messages []= "Your Password Must Contain At Least 1 Lowercase Letter!"; } if (empty($messages)) { return "Password is acceptable"; } return implode("\n", $messages); } $Passwords = array("donkeypass", "password", "Prebyt1na!", "1234", "abcd", "narW1@asndk", "pasS w0rd!", "maK%sh1ft", "mypasswordisthebestpasswordever!23493484023", "sD123#vAr2@y7"); foreach ($Passwords as $value) { echo validatePassword($value), "\n\n"; }
You have javascript disabled. You will not be able to edit any code.