fork download
  1. <?php
  2. function checked($a)
  3. {
  4. $check = array(
  5. "id",
  6. "name",
  7. "age",
  8. "email",
  9. "password",
  10. "birthday",
  11. "ip",
  12. "time",
  13. "token",
  14. "source"
  15. );
  16. $i = 0;
  17. foreach ($a as $key => $value) {
  18. if (in_array($key, $check)) {
  19. $i++;
  20. }
  21. }
  22. if ($i == 10) {
  23. $string = "Все ключи на месте, все $i";
  24. return $string;
  25. } else {
  26. $string = "Найдено всего $i ключей";
  27. return $string;
  28. }
  29. }
  30. $a = array(
  31. "id" => "12345",
  32. "name" => "Nikita",
  33. "age" => "23",
  34. "email" => "htk@gmail.com",
  35. "password" => "123456",
  36. "birthday" => "12 october",
  37. "ip" => "127.0.0.1",
  38. "time" => "12:12",
  39. "token" => "tok_en",
  40. "source" => "so_ur_ce",
  41. 'hello' => 'world'
  42. );
  43. echo checked($a);
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
Все ключи на месте, все 10