D
D
Daniil Sukhikh2018-04-04 08:12:44
PHP
Daniil Sukhikh, 2018-04-04 08:12:44

How to iterate logins from an array in PHP?

Here is the login verification code:

if ($date['login'] != $loginsp) {
  $errors[] = 'Ошибка: Не верный логин!';
}

It should iterate over the logins from the $loginsp variable, i.e. if 1 login did not fit, we try to pick up another one, but it always says that "Login is not correct!", how to make this code as I intended?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
unknown, 2018-04-04
@danchiksux

Use the in_array function

if (!in_array($date['login'], $loginsp)) {
      $errors[] = 'Ошибка: Не верный логин!';
}

L
Lone Ice, 2018-04-04
@daemonhk

if (isset($loginsp[$date['login']])) {
  //ваши действия по авторизации
}else{
  $errors[] = 'Ошибка: Не верный логин!';
}

Naturally, the array keys should be the logins themselves, as an option, you can hash everything and check the hashes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question