How to loop all pages but wrap every 3 with a div?

Thanks for your help, Texnixe! I’m making progress but my problem is that each column has a different number of items. For example the Appetizers section might have 10 items but the salad section might only have 5 items.

I found this thread: Creating a one-pager with subpages with your answer which helped, but I’m still having problems with the row looping. Heres my code:

<?php 
// grab your sections
$sections = page('menu')->children()->visible();

// helper variable
$count = 0;

// loop through sections
foreach($sections as $section):
  
//if the result of the modulo operation is 0, open new row
  if($count % 3 == 0): ?>
    <div class="row">
  <?php endif ?>

  <?php
  foreach(page('menu')->children()->visible() as $content):
	  snippet($content->intendedTemplate(), array('content' => $content));
  endforeach
  ?>

<?php 
 // if the result of the modulo operation is 2, close row
if($count % 3 == 2): ?>
    </div>
  <?php endif ?>
<?php $count++; endforeach ?>

Each row has duplicates of all of the children, rather than only having 3 children per row.