Answer the question
In order to leave comments, you need to log in
How to rewrite the code in a more simple and understandable form?
there is this snippet of code
foreach ($result as $i) {
if ($i['name'] == $name && $i['date'] == $day && print("<td>{$i['sub_hours']}</td>"))
continue 2;
}
Answer the question
In order to leave comments, you need to log in
Well, let's say we rewrite it like this.
foreach ($any as $result) {
foreach ($result as $i) {
if (isCheck($i, $name, $day)) {
print("<td>{$i['sub_hours']}</td>");
continue 2;
}
}
}
/**
* Проверка условия
*
* @param $itm
* @param $name
* @param $day
*
* @return bool
*/
function isCheck($itm, $name, $day)
{
if ($itm['name'] != $name) {
return false;
}
return ($itm['date'] == $day);
}
How to rewrite the code in a more simple and understandable form?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question