What are some best practices for optimizing performance in PHP loops?

When optimizing performance in PHP loops, it's important to minimize the number of function calls within the loop, avoid unnecessary variable assignments, and use efficient looping techniques like foreach instead of traditional for loops.

// Example of optimizing performance in PHP loops using foreach
$items = [1, 2, 3, 4, 5];
$result = 0;

foreach ($items as $item) {
    $result += $item;
}

echo $result;