0

I need to get all days in a year which fall in a Saturday and assign to each day the corresponding week number they fall on. This is because I need to cycle the number of weeks from 1 to 5 regardless of the month. So, every Saturday, a new week starts. After Week 5 ends, week 1 begins. Example:

JULY
__S___M___T___W___T___F___S____
 1 |  2|  3|  4|  5|  6|  7|   <--Week 1
 8 |  9| 10| 11| 12| 13| 14|   <--Week 2
 15| 16| 17| 18| 19| 20| 21|   <--Week 3
 22| 23| 24| 25| 26| 27| 28|   <--Week 4
 29| 30| 31                    <--Week 5

AUGUST
__S___M___T___W___T___F___S____
   |   |   |  1|  2|  3|  4|   <--Week 5
 5 |  6|  7|  8|  9| 10| 11|   <--Week 1
 12| 13| 14| 15| 16| 17| 18|   <--Week 2
 19| 20| 21| 22| 23| 24| 25|   <--Week 3
 26| 27| 28| 29| 30| 31|  1|   <--Week 4

My first guess was to get all Saturday dates in an indexed array and cycle the numeric key from 1 to 5, all the way until the last Saturday of the year. However im not an expert in PHP so i don't know where to start. Any idea?

GusztaveG
  • 1
  • 2

0 Answers0