What are the differences between using print_r() and echo for displaying array values in PHP, and when should each be used?

When displaying array values in PHP, `print_r()` is used to output human-readable information about one or more variables, including arrays. It is useful for debugging and displaying the structure of complex arrays. On the other hand, `echo` is used to output strings and does not provide a structured view of array elements. You should use `print_r()` when you need to see the structure of an array, while `echo` is more appropriate when you just need to display a specific element of an array.

// Using print_r() to display array values
$array = array('apple', 'banana', 'cherry');
print_r($array);

// Using echo to display a specific element of an array
echo $array[1];