3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ICL_LANGUAGE_CODE', 'en'); function the_title($str1, $str2) { echo $str1 . "House Sitting Days" . $str2; } $json = '{ "house_sitting_date_current_month": ["2020-02-01", "2020-02-02", "2020-02-03", "2020-02-04", "2020-02-05", "2020-02-06"], "house_sitting_date_yes_no_current_month": ["yes", "nada", "nada", "nada", "yes", "yes"], "house_sitting_date_next_month": ["2020-03-01", "2020-03-02", "2020-03-03", "2020-03-04", "2020-03-05", "2020-03-06"], "house_sitting_date_yes_no_next_month": ["no", "yes", "yes", "nada", "nada", "nada"], "toggle_status": null }'; $data_house = json_decode($json); $date = date("Y-m-d"); $sitting_day_str_en = "Sitting day"; $not_a_sitting_day_str_en ="Not a Sitting Day"; if (($k = array_search($date, $data_house->house_sitting_date_current_month)) !== false) { $sitting = $data_house->house_sitting_date_yes_no_current_month[$k]; $sitting_str_en = $sitting == 'yes' ? $sitting_day_str_en : ($sitting == 'no' ? $not_a_sitting_day_str_en : ''); } elseif (($k = array_search($date, $data_house->house_sitting_date_next_month)) !== false) { $sitting = $data_house->house_sitting_date_yes_no_next_month[$k]; $sitting_str_en = $sitting == 'yes' ? $sitting_day_str_en : ($sitting == 'no' ? $not_a_sitting_day_str_en : ''); } else { // not found $sitting_str_en = 'No data available'; } ?> <header class="entry-header container"> <?php the_title('<h1 class="entry-title-house">', '</h1>'); ?> <span class="current-date"><?php echo $date ?></span><!-- prints today's date--> // Line B <?php if (ICL_LANGUAGE_CODE == 'en') { ?> <!-- English --> <span class="current-date-answer"><?= $sitting_str_en ?></span> // Line C <?php } ?> </header>

preferences:
24.82 ms | 407 KiB | 5 Q