检查Variable是否比另一个变量小2

时间:2014-04-07 19:20:13

标签: php html css loops for-loop

我循环浏览一些数据并打印每一行。我对每一行做同样的事情,除了在for循环满足之前的最后一行我想省略我打印的东西之一。这是我正在使用的代码。

$i = 5;    

for($i=0; $i < $rsc; $i++) {


    print("<div><p>Date</p></div><div><p>My Name</p></div>");
    print("<div><p>Comment</p></div>");

    //This next piece should not print on the last run through.

    if(It's not the last one){
    print("<div><p> My Section Break</p></div>");
    }
}

1 个答案:

答案 0 :(得分:3)

for($i=0; $i < $rsc; $i++) {


    print("<div><p>Date</p></div><div><p>My Name</p></div>");
    print("<div><p>Comment</p></div>");

    //This next piece should not print on the last run through.

    if($i!=$rsc-1){
    print("<div><p> My Section Break</p></div>");
    }
}

希望这有效。

相关问题