fork download
  1. <?php
  2. function check($array){
  3. $checkAmount=0;
  4. $amount = count($array);
  5. if($amount==10){
  6. foreach ($array as $key => $value) {
  7. switch($key){
  8. case "id":
  9. $checkAmount++;
  10. break;
  11. case "name":
  12. $checkAmount++;
  13. break;
  14. case "age":
  15. $checkAmount++;
  16. break;
  17. case "email":
  18. $checkAmount++;
  19. break;
  20. case "password":
  21. $checkAmount++;
  22. break;
  23. case "birthday":
  24. $checkAmount++;
  25. break;
  26. case "ip":
  27. $checkAmount++;
  28. break;
  29. case "time":
  30. $checkAmount++;
  31. break;
  32. case "token":
  33. $checkAmount++;
  34. break;
  35. case "source":
  36. $checkAmount++;
  37. break;
  38.  
  39. }
  40. }
  41. if($checkAmount==10){
  42. echo "Элементов ровно 10!";
  43. }
  44. else {
  45. echo "Найдено всего {$checkAmount} элементов";
  46. }
  47. }
  48. else{
  49. echo "опаньки, элементов меньше 10..";
  50. }
  51. }
  52.  
  53. $dataArray= array(
  54. 'id'=>1231,
  55. 'name'=>"Ivan",
  56. 'age'=>23,
  57. 'email'=>"help@help.ru",
  58. 'password'=>"sadasdSda",
  59. 'birthday'=>"01.01.2011",
  60. 'ip'=>"77.154.5.12",
  61. 'time'=>"15:15:01",
  62. 'token'=>"asd",
  63. 'source'=>"asdasd"
  64. );
  65.  
  66. check($dataArray);
  67.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Элементов ровно 10!