I need to get the first and last date of the previous week. I use the code below and it works fine UNTIL I try to read the variable outside of the loop.

```
<?php
$current_week = date(W);
$previous_week = $current_week - 1;
$year = date(o);
for($day=1; $day<=7; $day++) {
  $temp = array ($day => date('Y-m-d', strtotime($year."W".$previous_week.$day)) . '   00:00:00');
  $firstday = $temp[1];
  // echo here works fine
  echo $firstday;
}

// echo here doesnt work anymore
echo $firstday;
?>

```

I really have no idea why this is not working. I've read through the PHP docs and everything tells me it should work.. I'm no wizz at all and I'm really confused now. Can anybody shine some light on this?

Thanks in advance!