I am creating a validation class in PHP. I want to validate two items in one array, and for some reason it only validates the first item. I call it like this:
Form::validate(array('user' => 'required', 'pass' => 'required'), 'login'); and the function is
public static function validate($rules, $form) { foreach ($rules as $rule => $val) { if ($val === 'required') { if (empty($_POST[$rule])) { if (isset($_POST[$form])) { self::$_error = Error::set('All fields are required. ' . $rule); echo self::$_error; return false; } } else { return true; } } } } My question is how I could validate both items in the one array?