What are the potential pitfalls of using print_r for debugging in PHP?

Using print_r for debugging in PHP can be problematic because it can output a lot of information that may be difficult to read and understand, especially for complex data structures. This can make it challenging to pinpoint the exact issue in the code. To solve this issue, you can use the var_dump function instead, which provides a more detailed and structured output for debugging purposes.

// Using var_dump for debugging instead of print_r
var_dump($variable_to_debug);