P
P
Pavel2020-05-05 09:33:03
PHP
Pavel, 2020-05-05 09:33:03

Why doesn't loop check work?

There is a two-dimensional array with dates and id, excerpt

123: {id: "240", off_date: "2020-05-02", off_id: "0"}
124: {id: "242", off_date: "2020-05-03", off_id: "0"}
125: {id: "245", off_date: "2020-05-08", off_id: "1"}


I'm trying to compare the selected date with the date in the array and its id, but for some reason it doesn't work out, tell me where to dig

$result_days = the array itself
$dText = date in the format 2020-05-03 for example
$tip_dnya="";
foreach ($result_days as $k) {
        if ($dText == $k["off_date"] && $k["off_id"] == 1) {
            $tip_dnya = "1";
        } elseif ($dText == $k["off_date"] && $k["off_id"] == 0) {
            $tip_dnya = "0";
        } else {
            $tip_dnya = "-";
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question