PHP中实现crontab代码分享(2)

){
                    return $start+$i;
            }
        }
        return null;
    }

/**
 * get a single cron style notation and parse it into numeric value
 *
 * @param string $s cron string element
 * @param int $min minimum possible value
 * @param int $max maximum possible value
 * @return int parsed number
 */
    protected static function _parseCronNumbers($s,$min,$max)
    {
        $result = array();

$v = explode(',',$s);
        foreach($v as $vv){
            $vvv = explode('https://www.jb51.net/',$vv);
            $step = empty($vvv[1])?1:$vvv[1];
            $vvvv = explode('-',$vvv[0]);
            $_min = count($vvvv)==2?$vvvv[0]:($vvv[0]=='*'?$min:$vvv[0]);
            $_max = count($vvvv)==2?$vvvv[1]:($vvv[0]=='*'?$max:$vvv[0]);

for($i=$_min;$i<=$_max;$i+=$step){
                $result[$i]=intval($i);
            }
        }
        ksort($result);
        return $result;
    }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/530deea62dcfdeb6d1e736117ac213f7.html