What are the limitations of using a for loop in PHP for sequential data retrieval and display?

One limitation of using a for loop in PHP for sequential data retrieval and display is that it requires knowing the exact number of iterations beforehand. If the number of elements in the data set is dynamic or unknown, a for loop may not be the best choice. In such cases, using a foreach loop can be more flexible as it automatically iterates over each element in an array or collection.

// Example of using a foreach loop for dynamic data retrieval and display
$data = [1, 2, 3, 4, 5];

foreach ($data as $item) {
    echo $item . "<br>";
}