Jump to content

Smarty for() loops?


Recommended Posts

I have this php code:

 

<?php

for($i=0;$i<30;$i+3){
   echo ('<tr><td>'.$letter[$].'</td><td>'.$letter[$i+1].'</td><td>'.$letter[$i+2].'</td></tr>');
}

?>

 

Basically, it displays:

 

<tr><td>Value 1</td><td>Value 2</td><td>Value 3</td></tr>
<tr><td>Value 4</td><td>Value 5</td><td>Value 6</td></tr>

 

Until it reaches value 30 (Excuse any errors, it's just for example's sake). My question is, is there a way to replicate this in smarty?

 

Thanks in advance

Link to comment
Share on other sites

Too late to change it, but I spotted an error:

 

echo ('<tr><td>'.$letter[$].'</td><td>'.$letter[$i+1].'</td><td>'.$letter[$i+2].'</td></tr>');

 

should be

 

echo ('<tr><td>'.$letter[$i].'</td><td>'.$letter[$i+1].'</td><td>'.$letter[$i+2].'</td></tr>');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.