最新消息: 新版网站上线了!!!

php简单的值日值班处理方法

header("Content-type:text/html;charset=utf-8");
$array = array('张三', '李四', '王五');
    $days = timeList(time(), strtotime('20150206000000'));
    foreach($days['dayList'] as $k=>$v){
        if(($k+1)%3 == 1){ $res[$v] = $array[0]; }
        if(($k+1)%3 == 2){ $res[$v] = $array[1]; }
        if(($k+1)%3 == 0){ $res[$v] = $array[2]; }
    }
    echo "<pre>"; print_r($res);exit;
 
    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'][]=date('Y年m月d日',$i);
        }
        return $tmp;
    }
 
/***
结果
Array
(
    [2014年12月19日] => 张三
    [2014年12月20日] => 李四
    [2014年12月21日] => 王五
    [2014年12月22日] => 张三
    [2014年12月23日] => 李四
    [2014年12月24日] => 王五
    [2014年12月25日] => 张三
    [2014年12月26日] => 李四
    [2014年12月27日] => 王五
    [2014年12月28日] => 张三
    [2014年12月29日] => 李四
    [2014年12月30日] => 王五
    [2014年12月31日] => 张三
    [2015年01月01日] => 李四
    [2015年01月02日] => 王五
    [2015年01月03日] => 张三
    [2015年01月04日] => 李四
    [2015年01月05日] => 王五
    [2015年01月06日] => 张三
    [2015年01月07日] => 李四
    [2015年01月08日] => 王五
    [2015年01月09日] => 张三
    [2015年01月10日] => 李四
    [2015年01月11日] => 王五
    [2015年01月12日] => 张三
    [2015年01月13日] => 李四
    [2015年01月14日] => 王五
    [2015年01月15日] => 张三
    [2015年01月16日] => 李四
    [2015年01月17日] => 王五
    [2015年01月18日] => 张三
    [2015年01月19日] => 李四
    [2015年01月20日] => 王五
    [2015年01月21日] => 张三
    [2015年01月22日] => 李四
    [2015年01月23日] => 王五
    [2015年01月24日] => 张三
    [2015年01月25日] => 李四
    [2015年01月26日] => 王五
    [2015年01月27日] => 张三
    [2015年01月28日] => 李四
    [2015年01月29日] => 王五
    [2015年01月30日] => 张三
    [2015年01月31日] => 李四
    [2015年02月01日] => 王五
    [2015年02月02日] => 张三
    [2015年02月03日] => 李四
    [2015年02月04日] => 王五
    [2015年02月05日] => 张三
)
 
**/

转载请注明:谷谷点程序 » php简单的值日值班处理方法