What potential issues can arise from nested if-else statements in PHP, and how can they be avoided?

Nested if-else statements can lead to code that is difficult to read and maintain, as the logic becomes more complex. To avoid this, consider using switch statements or refactoring the code into separate functions. This can help improve code readability and make it easier to debug and modify in the future.

// Example of refactoring nested if-else statements into separate functions

function processUserInput($input) {
    if ($input === 'A') {
        handleOptionA();
    } elseif ($input === 'B') {
        handleOptionB();
    } else {
        handleDefault();
    }
}

function handleOptionA() {
    // Logic for option A
}

function handleOptionB() {
    // Logic for option B
}

function handleDefault() {
    // Default logic
}

// Call the main function with user input
processUserInput('A');