Skip to content
Advertisement

Check day and do something if it is a workday or weekend

I want to to do something when the day is a workday, and do something else when it is a weekend.

But my function echoes “yes” every time, and I don’t get it.

JavaScript

Advertisement

Answer

Your current check is only checking to see if $dag_datumloop is equal to Monday. The rest are being evaluated on their own.

JavaScript

The other days would be evaluated as true because they’re all string values. The easiest way to check it would to be use in_array instead of doing $dag_datumloop == for each one:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement