0

I have two boxes displaying a header, subheader, and content. I have an array with the content for each box and I want to loop the array to add it's content to the boxes. This is the code I have, and it technically works, but I don't know if it's the best way to accomplish this task. I'm not even using the $value. Is there a better way to loop through this array?

<?
$dkBoxes = array(
    array(
        'header' => "Header 1",
        'subheader' => "Subheader 1",
        'content' => "Content in first box"
    ),
    array(
        'header' => "Header 2",
        'subheader' => "Subheader 2",
        'content' => "Content in second box"
    ),
);
$num = 0;
foreach ($dkBoxes as $value) {?>
                    <div class="col-lg-6">
                        <div class="box">
                            <h3><?= $dkBoxes[$num]['header'] ?></h3>
                            <p class="h2_style"><?= $dkBoxes[$num]['subheader'] ?></p>
                            <p><?= $dkBoxes[$num]['content'] ?></p>
                        </div>
                    </div>
<?
$num++;
}
?>
culiano
  • 3
  • 2

0 Answers0