What are some potential pitfalls of using while loops in PHP for array manipulation?

Using while loops for array manipulation in PHP can lead to infinite loops if not properly controlled, especially if the loop condition is not correctly defined. To avoid this pitfall, it's recommended to use foreach loops for array manipulation as they are specifically designed for iterating over arrays and are less error-prone.

// Example of using foreach loop for array manipulation
$numbers = [1, 2, 3, 4, 5];
foreach ($numbers as $number) {
    // Manipulate each element of the array here
    echo $number * 2 . "\n";
}