What are some best practices for debugging PHP code when dealing with array output?

When debugging PHP code that involves array output, it's important to first check the structure and contents of the array using functions like print_r() or var_dump(). This will help you identify any unexpected values or keys that may be causing issues. Additionally, using tools like xdebug or IDEs with debugging capabilities can help track the flow of the code and pinpoint where the issue lies.

// Example code snippet for debugging array output
$array = [1, 2, 3, 4, 5];
print_r($array);