fork download
  1. <?php
  2. $OKmassive = [
  3. 'id' => '666',
  4. 'name' => 'Petyan',
  5. 'age' => '18',
  6. 'email' => 'bitard@gmail.com',
  7. 'password' => '1488',
  8. 'birthday' => '11.09.2001',
  9. 'ip' => '127.0.0.0',
  10. 'time' => '02:39',
  11. 'token' => 'chto?',
  12. 'source' => 'www.2ch.hk/b'
  13. ];
  14. $BADmassive = [
  15. 'id' => '666',
  16. 'sex' => 'Petyan',
  17. 'age' => '18',
  18. 'email' => 'bitard@gmail.com',
  19. 'password' => '1488',
  20. 'birthday' => '11.09.2001',
  21. 'ip' => '127.0.0.0',
  22. 'time' => '02:39',
  23. 'token' => 'chto?',
  24. 'source' => 'www.2ch.hk/b'
  25. ];
  26.  
  27. function checking($mas){
  28. $rightKeys = ['id', 'name', 'age', 'email',
  29. 'password', 'birthday', 'ip',
  30. 'time', 'token', 'source'];
  31. $i = 0;
  32. foreach($mas as $key => $data){
  33. $a = ($key != $rightKeys[$i])? "suka" : "ok";
  34. if ($a == "suka"){
  35. return "pizdec";
  36. }
  37. $i++;
  38. }
  39. return "zaebis";
  40. }
  41.  
  42. $result = checking($OKmassive);
  43. echo "$result";
  44. ?>
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
zaebis