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
https://forums.phpfreaks.com/topic/108034-smarty-for-loops/
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
https://forums.phpfreaks.com/topic/108034-smarty-for-loops/#findComment-553736
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.