What potential problem does the "exit;" statement pose in a foreach loop in PHP?

The "exit;" statement in a foreach loop in PHP will immediately terminate the script execution, which may cause unexpected behavior and prevent the loop from completing its iterations. To solve this issue, you can use the "break;" statement to exit the loop without stopping the script execution.

foreach ($array as $item) {
    // code block

    if ($condition) {
        break; // exit the loop without stopping script execution
    }
}