Advertisement
Guest User

Untitled

a guest
Nov 28th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3. $users = [
  4.     'names' => [
  5.         'janusz',
  6.         'admin'
  7.     ],
  8.     'wallets' => [
  9.         500,
  10.         200
  11.     ],
  12.     'passwords' => [
  13.         'haslo',//haslo janusza
  14.         'admin'//haslo admina
  15.     ]
  16. ];
  17.  
  18. $login = 'somsiad';
  19. $password = 'haslo';
  20. helloUser($login, $password);
  21.  
  22. function helloUser(string $login, string $password)
  23. {
  24.     global $users;
  25.     $userId = array_search($login, $users['names'], true);
  26.     if (in_array(strtolower($login), $users['names'], true) and $password === $users['passwords'][$userId]) {
  27.         echo 'Witaj ' . $login . ', w twoim portfelu jest ' . $users['wallets'][$userId] . ' zł!';
  28.     } else {
  29.         echo 'Zły login lub hasło';
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement