- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 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;
}