how to begin an infinite loop, incremented daily
Posted: Mon Jan 05, 2009 11:30 am
Hi, I am a rather newbish, self-taught programmer and I can't wrap my ahead around this problem. I think it involves nested loops, but I'm not sure.
The ultimate goal here is I am going to be creating an RSS feed based on a series of sequential writings (call it 5 for our purposes). I want the feed to display the first item on January 1st, the 2nd on the second, etc. But on January 6th, I want the feed to display the 1st item again. And so on til infinity.
Here's what I have so far:
Now this obviously doesn't work because the first count (the date) only increments every time the second count is finished. Ideally, what I want is for this display:
0 - 0
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 0
7 - 1
8 - 2
...
I can't figure out how to make the first column of numbers begin at 0 and increment 1 for each day. Then the second column begins at 0 and increments until 5, then starts over.
I might be completely off in my approach. If it's completely confusing, refer to the goal stated above.
The ultimate goal here is I am going to be creating an RSS feed based on a series of sequential writings (call it 5 for our purposes). I want the feed to display the first item on January 1st, the 2nd on the second, etc. But on January 6th, I want the feed to display the 1st item again. And so on til infinity.
Here's what I have so far:
Code: Select all
for ( $i = 0; $i <= 365; $i++ ) {
echo $i . " - ";
for ( $j = 0; $j <= 5; $j++) {
echo $j . "<br />";
}
}
0 - 0
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 0
7 - 1
8 - 2
...
I can't figure out how to make the first column of numbers begin at 0 and increment 1 for each day. Then the second column begins at 0 and increments until 5, then starts over.
I might be completely off in my approach. If it's completely confusing, refer to the goal stated above.