我对如何过滤某个日期范围内的条目有一个逻辑问题。
一个数组$price
包含根据旅行时间段的航班价格,按日期排序:
print_r($price)
[21] => Array
[date_beg] => 2014-07-05
[total1] => 648
[22] => Array
[date_beg] => 2014-08-05
[total1] => 750
[23] => Array
[date_beg] => 2014-08-12
[total1] => 520
从 2014-08-05 开始是 648 欧元,然后从 2014-08-05 变成 750 ...
我在某些时期也有特别优惠。
数组的每个元素都存在相同的信息:
print_r($price)
[21] => Array
[date_beg] => 2014-07-05
[total1] => 648
[special_beg] => 2014-07-07
[special_end] => 2014-08-06
[special_price] => 600
[22] => Array
[date_beg] => 2014-08-05
[total1] => 750
[special_beg] => 2013-10-27
[special_end] => 2013-12-18
[special_price] => 600
[23] => Array
[date_beg] => 2014-08-12
[total1] => 520
[special_beg] => 2013-10-27
[special_end] => 2013-12-18
[special_price] => 600
我想做的是提供一个新的“显示”数组,其中包含促销有效的数组中每个元素的特价细节。
就像是:
$nb_date=0;
foreach($price as $a_price){
if (($a_price['special_beg']>$a_price['date_beg']))
//+ some other conditions
{
$display[$nb_date]'special_beg']=$a_price['special_beg'];
$display[$nb_date]'special_end']=$a_price['special_end'];
$display[$nb_date]'special_price']=$a_price['special_price'];
$display[$nb_date]'promo_web']=$a_price['promo_web'];
$display[$nb_date]['promo_text']=$a_price['promo_text'];
...etc...
}
$nb_date++;
}
我尝试了很多事情都没有成功。