If I have one php array $date
like below:
Array
(
[100] => Array
(
[card] => 5244
[start_date] => 2019-05-03 00:00:00
)
[93] => Array
(
[card] => 9526
[start_date] => 2019-05-20 00:00:00
)
[65] => Array
(
[card] => 1537
[start_date] => 2019-07-09 00:00:00
)
...
)
and I also have some random numbers like: 1, 34, 67, 120...
My question is that :
- when the random number is 1 or 34, then compare it with
$date
's keys (100, 93, 65), then return empty, - when the random number is 67, it will return
$date[65]
, because this number is between 65 and 93. - when the random number is 120, it will return
$date[100]
, because this number is between 100 and ∞ (infinite).
If the array $date
only has a few elements, I can use for or foreach to compare the keys, but if the array $date
has lots of elements, do we have an easy way to do that please?