Let's say I have an array as follows:
Array
(
[0] => 2017-09-14
[1] => 2017-09-15
[2] => 2017-09-16
[3] => 2017-09-17
[4] => 2017-09-18
[5] => 2017-09-19
)
Public function findClosestDate($dates_array, $fordate){
$mostRecent= 0;
foreach($dates_array as $date){
$curDate = $date;
if ($curDate >= $mostRecent && $curDate <= $fordate) {
$mostRecent = $curDate;
}
}
return $mostRecent;
}




No comments:
Post a Comment