就是这些被红字的数字,每行3个,所有偶数行的数字应该怎么通过数学的方法算出来?
取余的话取的是纵列的数字,怎么样能把红字的偶数行给表达出来?数学

解决方案 »

  1.   

    {wf:if $smarty.section.product.rownum eq 4 or $smarty.section.product.rownum eq 5 or $smarty.section.product.rownum eq 6 or $smarty.section.product.rownum eq 10 or $smarty.section.product.rownum eq 11 or $smarty.section.product.rownum eq 12}要输出的内容{qf:/if}现在我的写法是这样的,但是明显太不合理了,问下大神怎么写方便
      

  2.   

    int((n+2)/3) & 1 == 0
      

  3.   

    for ($n=1;$n<20;$n++){
        if(($n-1)/3%2 != 0)
            echo $n."\t";
    }
    //output: 4 5 6 10 11 12 16 17 18
      

  4.   

    for($i=1;$i<10;$i=$i+2){
    for($j=1;$j<=3;$j++){
    echo $i*3+$j.' ';
    }
    echo '<br />';
    }
      

  5.   

    smarty ??
    他不是有个 cycle 控制变量吗?为什么不用!
    test.php 
    include_once("smarty_inc.php"); 
    $arr=array('a','b','c','d','e','f'); 
    $smarty->assign('arr',$arr); 
    $smarty->display("test.tpl"); 
     
    test.tpl 
    <table width="100px"> 
    {section name=a loop=$arr} 
    <tr bgcolor="{cycle values="#eeeeee,#55eero"}"> 
    <td> 
    {$arr[a]} 
    </td> 
    </tr> 
    {/section} 
    </table>