PHP get last week date

If you want to get last week dates using php, that can be get from the following example.

// if not selected any filter, get last 7 days data
$dafaultStartDate		='';
$dafaultEndDate  		='';
$arrCurrentweek = array();
$i = 0;
$date = date('Y-n-j');
$time = time();
while($i<7)
{
     if(date('D', $time)!='Sun' && date('D', $time)!='Sat')
	 {
      $i++;
	  $arrCurrentweek[]=$date;
     }
     $time-= 86400;
     $date = date('Y-n-j', $time);
}
$dafaultEndDate	   =	$arrCurrentweek[0];
$dafaultStartDate  =	$arrCurrentweek[5];
echo "Start Date :- ".$dafaultStartDate;
echo "
"; echo "End Date :- ".$dafaultEndDate;

But above function display week start date and end date only.If you already know the week number and year you can get dates of that week, like this.

$week_number = 04;
$year = 2012;
for($day=1; $day<=7; $day++)
{
    echo date('Y-n-j', strtotime($year."W".$week_number.$day))."
"; }