What are some best practices for organizing data output in PHP using DIV elements?

When organizing data output in PHP using DIV elements, it is important to ensure that the code is clean and easy to maintain. One best practice is to separate the PHP logic from the HTML markup by using PHP to generate the necessary data and then outputting it within DIV elements in the HTML code.

<?php
$data = array("item1", "item2", "item3");

echo "<div>";
foreach($data as $item) {
    echo "<div>$item</div>";
}
echo "</div>";
?>