1. Список говнокодов пользователя govnocodegenerator

    Всего: 1

  2. PHP / Говнокод #16533

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    private function generate_accomodations_array($adults, $children, $ages) {
        $result = array();
        foreach($adults as $adult) {
          foreach($children as $child) {
            $param = array();
            if($child > 0) {
              for($age1=0; $age1<count($ages); $age1++) {
                if($child > 1) {
                  for($age2=$age1; $age2<count($ages); $age2++) {
                    $param = array($ages[$age1], $ages[$age2]);
                    $result[] = $this->generate_accomodations_row($adult, $child, $param);
                  }
                } else {
                  $param = array($ages[$age1]);
                  $result[] = $this->generate_accomodations_row($adult, $child, $param);
                }
              }
            } else {
              $result[] = $this->generate_accomodations_row($adult, $child, $param);
            }
          }
        }
        return $result;
      }
    
      private function generate_accomodations_row($adult = null, $child = null, $ages = null) {
        $result = array();
        if(!is_null($adult)) {
          $res_adult = array('adult' => $adult);
          $result = array_merge($result, $res_adult);
        }
        if(!is_null($child)) {
          $res_child = array('child' => $child);
          $result = array_merge($result, $res_child);
        }
        if(!is_null($ages)) {
          $res_ages = array();
          $i = 1;
          foreach($ages as $age) {
            $res_ages = array_merge(array('child-age'.$i++ => $age), $res_ages);
          }
          $result = array_merge($result, $res_ages);
        }
        if(!is_null($adult)) {
          for($i=0;$i<$adult;$i++) {
            $result['pegas_ages'][] = $this->adult_age;
          }
        }
        if(!is_null($ages)) {
          $result['pegas_ages'] = array_merge($result['pegas_ages'], $ages);
        }
        return $result;
      }

    govnocodegenerator, 14 Августа 2014

    Комментарии (0)