PHP foreach to array

Saturday, July 5, 2014

I try to grade from a foreach to form an array ... unfortunately I understand it not again.



$date = new DateTime('last sunday');
$interval = DateInterval::createFromDateString('+1 day');
$period = new DatePeriod($date, $interval, 7, DatePeriod::EXCLUDE_START_DATE);

foreach ( $period as $dt ){
echo $dt->format( "d.m.Y\n" )."<br>";
}


The array should be picturing so



$dat = array (
"Monday" => $dt->format("d.m.Y \ n"),
"Tuesday" => $dt->format("d.m.Y \ n"),
"Wednesday" => $dt->format("d.m.Y \ n"),
"Thursday" => $dt->format("d.m.Y \ n"),
"Friday" => $dt->format("d.m.Y \ n"),
"Saturday" => $dt->format("d.m.Y \ n"),
"Sunday" => $dt->format("d.m.Y \ n")
);


how do I do it in the foreach? can someone please help me?


thank you







http://ift.tt/1lHoOEc