Add banner after the third post [closed]

It’s not related to WordPress at all, it’s a generic PHP question, hence off-topic here. It’s easy, follow the inline comments, and you can have it. 🙂

<?php
//declare a counter
$counter = 1;

// Start the Loop.
while ( have_posts() ) : the_post();

/*
 * Include the post format-specific template for the content. If you want to
 * use this in a child theme, then include a file called called content-___.php
 * (where ___ is the post format) and that will be used instead.
 */
get_template_part( 'content', get_post_format() );

//check the counter and display your content
if( $counter === 3 ) { ?>
    <div class="third-div-in-loop">content</div>
<?php }

//update the counter on every loop
$counter++;

endwhile;