<?php /** * @param data 日期 array(start_date,end_data) */ function getDateByWeek($data) { $start_date = strtotime($data['start_date']); $end_date = strtotime($data['end_date']); $days = ($end_date - $start_date) / 86400; $weekArr = array('周日','周一','周二','周三','周四','周五','周六'); $newDate = array(); // 组建数组格式 $dataWeek['日期'] => 星期 for ($i=0; $i < $days; $i++) { $num_week = date('w',$start_date+($i*86400)); $dateWeek[date('Y-m-d',$start_date+($i*86400))] = $weekArr[$num_week]; } // 查找两个数组的交集,即获取提交的星期对应的日期 $newDate=array_intersect($dateWeek,$data['items']); // 获取数组中的键值(日期),并组成一个新数组 $date = array_keys($newDate); return $date; } ?>
本文结束