<?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