简体   繁体   中英

Check if Variable is 2 less than another Variable

I am looping through some data and printing for every row. I do the same thing for every row except on the last one before the for loop is satisfied I want to omit one of the things I print. Here is the code I'm using.

$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>");
    }
}
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>");
    }
}

Hope this works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM