fork download
  1. <?php
  2.  
  3. $dados = array("1","2","3","4","5","6","7","8");
  4.  
  5. echo '
  6. <div class="container">
  7. <div class="row">'.PHP_EOL;
  8.  
  9. $i=1;
  10.  
  11. foreach($dados as $col) {
  12.  
  13. echo '<div class="col-sm-4">'.$col.'</div>';
  14.  
  15. if ($i%3==0) {
  16. echo PHP_EOL.'</div><div class="row">'.PHP_EOL;
  17. }
  18.  
  19. $i++;
  20. }
  21.  
  22. echo '
  23. </div>
  24. </div>'.PHP_EOL;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
<div class="container">
	<div class="row">
<div class="col-sm-4">1</div><div class="col-sm-4">2</div><div class="col-sm-4">3</div>
</div><div class="row">
<div class="col-sm-4">4</div><div class="col-sm-4">5</div><div class="col-sm-4">6</div>
</div><div class="row">
<div class="col-sm-4">7</div><div class="col-sm-4">8</div>
	</div>
</div>