How to design the bootstrap columns dynamically in php ? – GeeksforGeeks

<?php

  

    

    function generateColumn($size, $content, $bg)

    {

        $html = '<div class="col-' . $size

        ' bg-' . $bg  . ' p-3 border border-5">';

        $html .= $content;

        $html .= '</div>';

        return $html;

    }

?>

<!DOCTYPE html>

<html>

  

<head>

    <title>Bootstrap Columns Example</title>

    <!-- Include Bootstrap CSS -->

    <link rel="stylesheet"  href=

</head>

  

<body>

    <div class="container">

        <div class="my-4">

            <h1 class="text-success">GeeksforGeeks</h1>

            <h5>Dynamically Generated Bootstrap Columns</h5>

        </div>

  

        <div class="row">

            <?php

            

            $columns = array(

                array(

                    'size' => 6,

                    'content' => 'Column 1',

                    'background' => 'primary'

                ),

                array(

                    'size' => 6,

                    'content' => 'Column 2',

                    'background' => 'warning'

                ),

                array(

                    'size' => 4,

                    'content' => 'Column 3',

                    'background' => 'info'

                ),

                array(

                    'size' => 8,

                    'content' => 'Column 4',

                    'background' => 'success'

                )

            );

  

            

            foreach ($columns as $column) {

                

                $colSize = $column['size']; 

                

                $colContent = $column['content']; 

                

                $colBg = $column['background']; 

                echo generateColumn($colSize, $colContent, $colBg);

            }

            ?>

        </div>

    </div>

</body>

</html>

 

Stay connected with us on social media platform for instant update click here to join our  Twitter, & Facebook We are now on Telegram. Click here to join our channel (@TechiUpdate) and stay updated with the latest Technology headlines. For all the latest Technology News Click Here 

Read original article here

Denial of responsibility! FineRadar is an automatic aggregator around the global media. All the content are available free on Internet. We have just arranged it in one platform for educational purpose only. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials on our website, please contact us by email – abuse@fineradar.com. The content will be deleted within 24 hours.
Bootstrapcolumnsdesigndynamicallyfineradar updateFree Fire Redeem Codesgadget updateGeeksforGeeksLatest tech newsPHPTech Headlinestech newsTech News UpdatesTechnologyTechnology News
Comments (0)
Add Comment