<?php
function getSundays($y, $m)
{
return new DatePeriod(
new DateTime("first Sunday of $y-$m"),
DateInterval::createFromDateString('next sunday'),
new DateTime("last day of $y-$m")
);
}
$days="";
foreach (getSundays(2016, 04) as $Sunday) {
$days[] = $Sunday->format("d");
}
var_dump($days);
Fatal error: Uncaught Error: [] operator not supported for strings in /in/DVYM5:14
Stack trace:
#0 {main}
thrown in /in/DVYM5 on line 14
Process exited with code 255.