What are some common mistakes to avoid when working with arrays and loops in PHP, as seen in the provided code snippet?

One common mistake to avoid when working with arrays and loops in PHP is not properly initializing variables before using them within a loop. This can lead to unexpected behavior or errors in the code. To solve this issue, make sure to initialize variables before using them within a loop to avoid any potential problems. Example:

// Incorrect code snippet
$numbers = [1, 2, 3, 4, 5];
$total = 0;

foreach ($numbers as $number) {
    $total += $number;
}

echo "Total: " . $total;

// Corrected code snippet
$numbers = [1, 2, 3, 4, 5];
$total = 0;

foreach ($numbers as $number) {
    $total += $number;
}

echo "Total: " . $total;