Wrap every 2 divs in row – for each loop [closed]

You need to create a variable with the count and then check against it e.g.

$num = 1;
foreach ( $terms as $term ) { 
 if($num%2) {
  echo '<div class="something">';
 }

 // other stuff

 if($num %2) {
  echo '</div>';
 }
 $num++
}

The %2 is the part you need, it checks whether the number is dividable by 2