What are the potential pitfalls of nesting multiple loops in PHP code?

Nesting multiple loops in PHP code can lead to decreased readability, increased complexity, and potential performance issues. To avoid these pitfalls, consider refactoring the code to use alternative constructs like array functions or breaking down the nested loops into separate functions.

// Example of refactoring nested loops into separate functions

function processNestedArrays($array1, $array2) {
    foreach ($array1 as $item1) {
        processItem($item1);
        
        foreach ($array2 as $item2) {
            processItem($item2);
        }
    }
}

function processItem($item) {
    // Process the item here
}