I have this effective date and the array start and repeat every 12 cycles. How do I check the item value of a specific date then?
I've tried to get the item value for specific date start from the effective date but it returns no value.
<?php
$start_date = '2019-01-01';
$end_date = '2019-01-30';
$item = array('a','a','a','a','o','o','b','b','b','b','o','o');
$i = 0;
while (strtotime($start_date) <= strtotime($end_date)) {
$i = $i+1;
$value = $item[$i];
if($start_date == '2019-01-05') {
echo "Date:".$start_date." Value:".$value;
echo "</br>";
}
if($start_date == '2019-01-07') {
echo "Date: ".$start_date." Value: ".$value;
echo "</br>";
}
if($start_date == '2019-01-25') {
echo "Date: ".$start_date." Value: ".$value;
echo "</br>";
}
$start_date = date ("Y-m-d", strtotime("+1 day", strtotime($start_date)));
}
?>
I expect the output to be like:
Date:2019-01-05 Value:o
Date: 2019-01-07 Value: b
Date:2019-01-25 Value:a
But I get:
Date:2019-01-05 Value:o
Date: 2019-01-07 Value: b
Date:2019-01-25 Value:
How to get nth value of the date every 12 cycles start from the effective date?