How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?

I think including a counter like this would do the trick. Does this help?

<?php

$showposts=2;

$counter=0;
while ( bbp_topics() ) : bbp_the_topic();
   $counter++;
   if(counter<=$showposts) {
?>

      /*** Do stuff ***/

<?php
   }   
   else {
      break;
   }
endwhile;
?>

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedusedusedusedusedusedueduedusedu