What are the potential pitfalls of using both echo and print_r in PHP code?

Using both echo and print_r in PHP code can lead to unexpected output and formatting issues. It is recommended to use only one of these functions to avoid confusion and maintain consistency in the output. To solve this issue, choose either echo or print_r based on the desired output format and stick to using that function throughout the code.

// Example of using only echo to output a variable
$variable = [1, 2, 3];
echo "Array contents: " . implode(", ", $variable);