<?php
$price = array( );
$price = array ( "adult" => array(), "child" => array());
$price['adult'][1]['2014-05-01'] = array();
$price['adult'][1]['2014-05-01']['basic_price'] = 100.00;
$price['child'][1]['2014-05-01'] = array();
$price['child'][1]['2014-05-01']['basic_price'] = 0.00;
$price['child'][1]['2014-05-01']['hotel_child'] = 396;
$price['child'][2]['2014-05-01'] = array();
$price['child'][2]['2014-05-01']['basic_price'] = 10.00;
$price['child'][2]['2014-05-01']['hotel_child'] = 407;
$occ[0]['bdate'] = '01.05.2006';
$occ[0]['hotel_child_id'] = 407;
print "<pre> <h4>Childovi:</h4> <br>";
print_r($occ);
print "</pre>";
#print "<pre> <h4>Price arra:</h4> <br>";
#print_r($price);
#print "</pre>";
$child_id = 396;
function chk($id, $arr) {
foreach ($arr as $a => $v) {
if ($v['hotel_child_id'] == $id) {
return true;
}
}
}
foreach ($price as $pr => $val) {
if ($pr == "child") {
foreach ($val as $ch => $vv) {
foreach ($vv as $d => $v) {
if (chk($v['hotel_child'], $occ)) {
print $v['hotel_child'] . "<br>";
} else {
unset($price[$pr][$ch]);
}
}
}
}
}
print "Posle: <br><br> <pre>";
print_r($price);
print "</pre>";
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- <pre> <h4>Childovi:</h4> <br>Array
(
[0] => Array
(
[bdate] => 01.05.2006
[hotel_child_id] => 407
)
)
</pre>407<br>Posle: <br><br> <pre>Array
(
[adult] => Array
(
[1] => Array
(
[2014-05-01] => Array
(
[basic_price] => 100
)
)
)
[child] => Array
(
[2] => Array
(
[2014-05-01] => Array
(
[basic_price] => 10
[hotel_child] => 407
)
)
)
)
</pre>
preferences:
306.29 ms | 407 KiB | 389 Q