Try something like this. You should assign default values for those three variables in case there's no match (for the weeks being checked). I'm assuming that the view weeks will always have the same number of weeks as the first array. If not, split out the code into two separate 'for' loops. You could have just one set of arrays where it goes from 08/09 to 8/15 for the first values. I don't know why you have a $file and $view_file variables if they contain the same thing. You only need one, but I left it in this example code.
$today = date('Ymd');
$weeks = array(1 => array(20050809, 20050813),
array(20050816, 20050820),
array(20050823, 20050827),
array(20050830, 20050903)
);
$view_weeks = array(1 => array(20050814, 20050815),
array(20050821, 20050822),
array(20050828, 20050829),
array(20050904, 20050905)
);
for ($i=1, $cnt=count($weeks); $i <= $cnt; $i++) {
if ((($weeks[$i][0] <= $today) && ($weeks[$i][1] >= $today)) ||
((($view_weeks[$i][0] <= $today) && ($view_weeks[$i][1] >= $today)))) {
$file = "week$i.dat";
$view_file = "week$i.dat";
$week_name = "WEEK $i";
break;
}
}