下面是循環內的數組: 我想通過[date-begin]和[date-end] 來過濾這個數組。例如,如果我發佈startdate = 2015-06-29和enddate = 2015-08-29 然後這個範圍之間的數組數據應該出現。按元素過濾數組
我想:
1. array_slice
2.foreach(range ($startdate,$enddate) as $data){
echo "Age: {$data}<br />";
}
Array
(
[name] => MCLE 201
[date-begin] => 2015-06-29
[date-end] => 2015-06-29
)
Array
(
[name] => MCLE 201
[date-begin] => 2015-07-29
[date-end] => 2015-07-29
)
Array
(
[name] => MCLE 201
[date-begin] => 2015-08-29
[date-end] => 2015-08-29
)
Array
(
[name] => MCLE 201
[date-begin] => 2015-09-29
[date-end] => 2015-09-29
)
看看array_filter或嘗試foreach –