I have a php code as shown below:
Php Code:
<?php
the_title('<h1 class="position">', '</h1>');
echo '<span class="data">' .date('yy-m-d'). '</span>'; // Line B
echo '<span class="part">Sitting Day</span>'; // Line C
?>
The above php code (Line B and Line C) prints the following: I am using Sitting Day at Line C (just for fun) but it should print what is inside the JSON below:
JSON:
{
"position_day": ["2020-01-15", "2020-01-16", "2020-01-17"],
"proc_no": ["no", "yes", "no"]
}
Edit 1: I am not controlling the JSON. The values inside the JSON are passed via UI.
Problem Statement:
I am wondering what changes I should make in the php code above (specially at Line B and Line C) so that Line B looks/match/scan for a date inside the JSON above and print content at Line C on the basis of date in the JSON.
Case 1: If today's date is 2020-01-15 at Line B and its no for the corresponding date in the JSON, then it should say Not a Sitting Day at Line C.
Case 2: If today's date is 2020-01-16 at Line B and its yes for the corresponding date in the JSON, then it should say Sitting Day at Line C.
Case 3: If today's date is 2020-01-22 at Line B and nothing is present in the JSON for that particular date, then it should say display blank/nothing at Line C.
house_sitting_dates: [{ "date":"2020-01-15", "did_sit": false}, {"date":"2020-01-16", "did_sit": true}]. Otherwise, when you loop through one of them, just keep a reference to the index and spit out the same indexed value from the other array.