How can you reset an array in a while loop in PHP?

When resetting an array in a while loop in PHP, you can simply reassign an empty array to the variable holding the array data. This will clear out the existing array elements and allow you to start fresh within the loop.

$array = [1, 2, 3, 4, 5];
$index = 0;

while ($index < 5) {
    // Do something with the array elements

    // Reset the array for the next iteration
    $array = [];
    
    $index++;
}