php-store-hours icon indicating copy to clipboard operation
php-store-hours copied to clipboard

if no exceptions are specified, php spams warnings about 'Invalid argument supplied for foreach()'

Open kn00tcn opened this issue 5 years ago • 0 comments

are these two blocks causing php warnings?

foreach ($this->exceptions as $key => $value) {
    $this->exceptions[$key] = array_filter($value, function ($element) {
        return (trim($element) !== '');
    });
}
foreach ($this->exceptions as $ex_day => $ex_hours) {
    if (strtotime($ex_day) === $today) {
        // Today is an exception, use alternate hours instead
        $hours_today = $ex_hours;
    }
}

wrapping them with if ($this->exceptions) seems to stop the warnings, not sure if isset should be used

kn00tcn avatar Apr 02 '19 03:04 kn00tcn