I have an array of id's and unix times
$array = Array(
[12] => 14235183200,
[8] => 1443045600,
[1] => 1417388400
);
and current time $curr_time = time();. I need to check which of these is the closest to the current time, and then to get the key of the array for that value which is the closest. If the time has passed, then of course that value shouldn't count (only future dates are important).
min() should give me lowest value of the compared values. But if I put current date, any future date is greater, and I get current date as a result. array_search() will give me key I needed. So I need this:
$key = array_search($array, $min_date);
where $min_date is the date closest to the current one from the array. But how to preform the check? I tried with foreach($array as $value), but when i tried
foreach($array as $value){
}
any test fails since $value is a string of all values combined.