I need to populate a file with past unix time stamps over a period of time
specified by the user. The time stamps should be evenly spaced, based on
user-defined parameters.
My question is: How do I add an element to an array, then increment it and
loop so that each element builds on the previous element just added?
Here's a first crack at it:
<?php
$data_file = 'timedata.txt';
$avdaily = 25 //user-defined
$total_count = (183 * $avdaily) //time period = six months
$interval = (3600*24)/$avdaily //evenly spaced intervals
$first_time = time() - (3600*24*183)
$next_time = ($first_time + $interval)
//add $next_time to $data_array -- here's where I'm lost
$next_time = ($next_time + $interval)
//add $next_time to $data_array
//loop until $data_array has $total_count elements
//write $data_array to $data_file
//newest time should be last line in file
?>
This output should be a file that has a
series of unix time stamps incremented
by the amount of $interval. The below output
example increments by 10 seconds each iteration.
1081111110
1081111120
1081111130
1081111140
1081111150
1081111160
1081111170
1081111180
1081111190
Any help is appreciated! Thanks.