How can you dynamically create a variable number of DIV containers in PHP?

To dynamically create a variable number of DIV containers in PHP, you can use a loop to generate the desired number of containers. You can store the number of containers in a variable and then use a for loop to create each container with unique IDs or classes. This allows you to easily adjust the number of containers created based on your needs.

<?php
$numContainers = 5;

for ($i = 1; $i <= $numContainers; $i++) {
    echo "<div id='container$i'>Container $i</div>";
}
?>