Reputation: 1210
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>");
}
}
Upvotes: 1
Views: 85
Reputation: 1126
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.
Upvotes: 3