从2000年1月1日开始“三天打渔,两天晒网”算,求任意一天打渔还是晒网?

解决方案 »

  1.   

    strtotime……可计算一定范围内的,
      

  2.   

    <?php
    $s=strtotime('2000-1-1');
    $time=strtotime('2012-5-11');
    $sum=($time-$s)/86400;
    $day=$sum%5;
    echo $day<=3?'打渔':'晒网';
      

  3.   

    N%5  
    >=1 && <= 3 的打渔 否则 晒网
      

  4.   

    <?php
    $s=strtotime('2000-1-1');
    $time=strtotime('2001-5-27');
    $sum=($time-$s)/86400;
    $day=$sum%5+1;
    echo $day<=3?'打渔':'晒网';
      

  5.   

    写个函数了。
    function GetText($day)
    {
    $nowDay = date("z", strtotime($day)) + 1;
    Return ($nowDay%5 >= 1 && $nowDay%5 <=3) ? '晒网' : '打鱼';
    }echo GetText('2011-01-01');
      

  6.   

    应该这样吧。文字调换了一下。
    function GetText($day)
    {
    $nowDay = date("z", strtotime($day)) + 1;
    Return ($nowDay%5 >= 1 && $nowDay%5 <=3) ? '打鱼' : '晒网';
    }echo GetText('2011-01-01');
      

  7.   

    计算的不准是因为天数差计算有误给个最笨的方法,供你参考。你不是在做作业吗?$t = strtotime('2000-1-1');
    $i = 0;
    while($t < time()) {
      echo date('Y-m-d', $t) . ' '. ($i < 3 ? '打渔' : '晒网') . PHP_EOL;
      $t = strtotime('+1 day', $t);
      $i = ($i+1) % 5;
    }
      

  8.   

    <form action="fish.php">
    年份:
    <input type="text" name="year"/>
    <br/>
    月份:
    <input type="text" name="month"/>
    <br/>
    日期:
    <input type="text" name="day"/>
    <br/>
    <input type="submit" name="submit1" value="提交"/>
    </form><?php
    $y=$_GET['year'];
    $m=$_GET['month'];
    $d=$_GET['day'];
    function is_leap($x){
    if($x%4==0&&$x%100!=0||$x%400==0)
    return 1;
    else 
    return 0;
    }
    $s=$d;
    if(is_leap($y)==1) 
    $mon[2]=29;
    for($i=2000;$i<$y;$i++){
    if(is_leap($i)==1)
    $s=$s+1;
    }
    echo $s;
    switch ($s%5)
    {
    case 1:echo"打渔";break;
    case 2:echo"打渔";break;
    case 3:echo"打渔";break;
    case 4:echo"晒网";break;
    case 0:echo"晒网";break;
    }
    ?>
      

  9.   

    <form action="fish.php">
    年份:
    <input type="text" name="year"/>
    <br/>
    月份:
    <input type="text" name="month"/>
    <br/>
    日期:
    <input type="text" name="day"/>
    <br/>
    <input type="submit" name="submit1" value="提交"/>
    </form>