I have a file that contains the output of time(). A different time is on
each line of the file, and each line represents a visit to the website. I
want to calculate the total visits per day, month and year. So, I dump the
file into an array, and then iterate through the array testing each element
and incrementing a counter for each respective time period.
But what is the best way to iterate through the array? The foreach($av)
does not seem to be working. Any help is appreciated. Thanks.
$viscounter = 'viscounter';
// this is all that's in the file (will be hundreds of lines):
1089828547
1089828548
1089828549
1089828550
$av = file($viscounter);
$v24h = 0;
$v30d = 0;
$v365d = 0;
foreach($av) // ????????
{
if($av>time()-(3600*24))
{
++$v24h;
}
if($av>time()-(3600*24*30))
{
++$v30d;
}
if($av>time()-(3600*24*365))
{
++$v365d;
}
}
echo "<br>v24h=".$v24h;
echo "<br>v30d=".$v30d;
echo "<br>v365d=".$v365d;