如何在php中的一个条件中添加多个条件

I want to add this multiple condition in one condition to make it simple, below is my code. I want if the value of "footer_widgets_columns" is 4 then show all 4 columns and if 3 then show only and so on, this code is working to my requirement but want to make it more compact in one condition rather than writing it again and again

<section class="columns columns-<?php echo $data['footer_widgets_columns']; ?>">

                <?php if($data['footer_widgets_columns']== 4){
                    $footer_col=3;
                ?>  
                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 3')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?> last">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 4')): 
                endif;
                ?>
                </article>
                <?php
                }
                ?>

                <?php if($data['footer_widgets_columns']== 3){
                    $footer_col=4;
                ?>  
                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 3')): 
                endif;
                ?>
                </article>

                <?php
                }
                ?>

                <?php if($data['footer_widgets_columns']== 2){
                    $footer_col=6;
                ?>  
                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')): 
                endif;
                ?>
                </article>

                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 2')): 
                endif;
                ?>
                </article>

                <?php
                }
                ?>

                <?php if($data['footer_widgets_columns']== 1){
                    $footer_col=12;
                ?>  
                <article class="col-md-<?php echo $footer_col ?>">
                <?php
                if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget 1')): 
                endif;
                ?>
                </article>

                <?php
                }
                ?>

            </section>

You can do something like

<?php
$footer_col = 12 / $data["footer_widgets_columns"];
for($i=1; $i <= $data["footer_widgets_columns"]; $i++)
{
if($i != 4){
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget '.$i)): 
endif;
?>
</article>
<?php 
}
else{
?>
<article class="col-md-<?php echo $footer_col ?>" last>
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget '.$i)): 
endif;
?>
</article>
<?php
}
} 
?>