PHP完全自学手册(珍藏版) 中文pdf扫描版下载
<?php
/***
懒人程序
**/
/***
懒人程序
**/
header("Content-type:text/html;charset=utf-8");
$array = array('客服1', '客服2', '客服3','客服4');
$days = timeList(time(), strtotime('20180206000000'));
foreach($days['dayList'] as $k=>$v){
if(($k+1)%4 == 1){ $res[$v] = $array[0]; }
if(($k+1)%4 == 2){ $res[$v] = $array[1]; }
if(($k+1)%4 == 3){ $res[$v] = $array[2]; }
if(($k+1)%4 == 0){ $res[$v] = $array[3]; }
}
$file = "./duty.php";
if(file_exists($file)){
$filename = file_get_contents($file);
$date = strtotime(date("Y-m-d"));
$dates = strtotime('+20 days',strtotime(date("Y-m-d")));
$filename = include($file);
foreach($filename as $key=>$value) {
if($key==$date) {
echo "今日值班".date("Y-m-d",$key).'===>'.$value.'===>'.getWeek($key).'
';
}
if($key<$date){
continue;//过滤掉今天以前的数据
}
if($dates<$key){
continue;//过滤掉20天以后的数据
}
$new[$key] = $value;
echo date("Y-m-d",$key).'===>'.$value.'===>'.getWeek($key).'
';
}
//重组数据 输出 $new
} else {
file_put_contents($file, "\nreturn " . var_export($res, true) . ";");
}
function timeList($beginTimeStamp,$endTimeStamp){
if(!is_numeric($beginTimeStamp)||!is_numeric($endTimeStamp)||($endTimeStamp<=$beginTimeStamp)) return '';
$tmp=array();
for($i=$beginTimeStamp;$i<=$endTimeStamp;$i+=(24*3600)){
$tmp['dayList'][]=strtotime(date('Y-m-d',$i));
}
return $tmp;
}
function getWeek($time) {
$weekarray=array("日","一","二","三","四","五","六");
$week = $weekarray[date('w',$time)];
if($week=='日') {
return "\"color:#D83A09\">周".$weekarray[date('w',$time)]."";
} elseif($week=='六') {
return "\"color:#D83A09\">周".$weekarray[date('w',$time)]."";
} else {
return "周".$weekarray[date('w',$time)];
}
}
/***
*
* 输出结果
* 今日值班2015-01-04===>客服1===>周日
2015-01-04===>客服1===>周日
2015-01-05===>客服2===>周一
2015-01-06===>客服3===>周二
2015-01-07===>客服4===>周三
2015-01-08===>客服1===>周四
2015-01-09===>客服2===>周五
2015-01-10===>客服3===>周六
2015-01-11===>客服4===>周日
2015-01-12===>客服1===>周一
2015-01-13===>客服2===>周二
2015-01-14===>客服3===>周三
2015-01-15===>客服4===>周四
2015-01-16===>客服1===>周五
2015-01-17===>客服2===>周六
2015-01-18===>客服3===>周日
2015-01-19===>客服4===>周一
2015-01-20===>客服1===>周二
2015-01-21===>客服2===>周三
2015-01-22===>客服3===>周四
2015-01-23===>客服4===>周五
2015-01-24===>客服1===>周六
*/
转载请注明:谷谷点程序 » php值班值日程序高级版【原创】