这是我的代码,当我运行这个函数时,我得到这个:Warning: array_push() expects parameter 1 to be array
但是我$printed
在开始之前定义为一个数组。
$printed = array();
function dayAdvance ($startDay, $endDay, $weekType){
$newdateform = array(
'title' => date("M d", strtotime($startDay))." to ".date("M d", strtotime($endDay)). $type,
'start' => $startDay."T08:00:00Z",
'end' => $startDay."T16:00:00Z",
'url' => "http://aliahealthcareer.com/calendar/".$_GET['fetching']."/".$startDate);
array_push($printed, $newdateform);
if ($weekType=="weekend"){
$days="Saturday,Sunday";
}
if ($weekType=="day"){
$days="Monday,Tuesday,Wednesday,Thuresday,Friday";
}
if ($weekType=="evening"){
$days="Monday,Tuesday,Wednesday";
}
$start = $startDate;
while($startDay <= $endDay) {
$startDay = date('Y-m-d', strtotime($startDay. ' + 1 days'));
$dayWeek = date("l", strtotime($startDay));
$pos = strpos($dayWeek, $days);
if ($pos !== false) {
$newdateform = array(
'title' => date("M d", strtotime($start))." to ".date("M d", strtotime($endDate)). $type,
'start' => $startDate."T08:00:00Z",
'end' => $startDate."T16:00:00Z",
'url' => "http://aliahealthcareer.com/calendar/".$_GET['fetching']."/".$startDate);
array_push($printed, $newdateform);
}
}
}