I have a php code as shown below:
Php Code:
if (file_exists('feeds/ptp-ess_landing_house.json')) {
$data_house = json_decode(file_get_contents('feeds/ptp-ess_landing_house.json'));
}
<?php
the_title('<h1 class="entry-title-house">', '</h1>');
echo '<span class="current-date">' .date('yy-m-d'). '</span>'; // Line B
echo '<span class="current-date-answer">Sitting Day</span>'; // Line C
?>
The above php code (Line B and Line C) prints the following:
House Portal 2020-01-17 Sitting Day
I am using Sitting Day at Line C (just for fun) but it should print what is inside the JSON below:
JSON:
Here is the JSON(feeds/ptp-ess_landing_house.json)
which I have right now:
{
"house_sitting_date": ["2020-01-15", "2020-01-16", "2020-01-17"],
"house_sitting_date_yes_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 and print content on the basis of date.
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.