What are the best practices for debugging PHP code that involves complex loops and conditional statements?

When debugging PHP code that involves complex loops and conditional statements, it is important to break down the code into smaller parts and test each part individually. Use print statements or var_dump() function to display the values of variables at different stages of the loop or conditional statement to identify any issues. Additionally, consider using a debugger tool like Xdebug to step through the code and track variable values in real-time.

// Example code snippet with complex loop and conditional statement
$numbers = [1, 2, 3, 4, 5];

foreach ($numbers as $number) {
    if ($number % 2 == 0) {
        echo $number . " is even. ";
    } else {
        echo $number . " is odd. ";
    }
}