Advertisement
Guest User

Untitled

a guest
May 25th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. $userLogin = [];
  3. $count = 0;
  4. while(true) {
  5.     $input = trim(fgets(STDIN));
  6.     if ($input == "login") {
  7.         break;
  8.     }
  9.     $line = explode(' -> ', $input);
  10.     $userLogin[$line[0]] = $line[1];
  11. }
  12. while(true) {
  13.     $input = trim(fgets(STDIN ));
  14.     if ($input == "end"){
  15.             break;
  16.     }
  17.     $line = explode(' -> ', $input);
  18.     if (!key_exists || !value_exists) {
  19.         echo "$key: login failed" . PHP_EOL;
  20.             $count++;
  21.     } else {
  22.                 echo "$key: logged in successfully" . PHP_EOL;
  23.     }
  24. }
  25. echo "unsuccessful login attempts: $count";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement