Skip to content
Advertisement

PHP loop through months array

This should be easy but I’m having trouble…

In PHP how can I echo out a select drop down box that defaults to the current month and has options for 8 months prior (even if it goes in the last year).

For example, for this month it would default to June and end at November.

Advertisement

Answer

JavaScript

Alternative for “custom” month names:

JavaScript

To output an array of such months as dropdown is as simple as:

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