What are the potential pitfalls of using do-while loops in PHP, as seen in the provided code snippet?

The potential pitfall of using do-while loops in PHP is that the loop will always execute at least once, even if the condition is initially false. This can lead to unexpected behavior if the loop should not run at all under certain conditions. To solve this issue, you can use a while loop instead, which checks the condition before executing the loop body.

// Example of using a while loop instead of a do-while loop
$counter = 0;

while ($counter < 5) {
    echo $counter . "<br>";
    $counter++;
}