How can the PHP function print_r be helpful when working with arrays in PHP?

When working with arrays in PHP, it can sometimes be difficult to visualize the structure of the array and its contents. The PHP function print_r is helpful in this situation as it allows you to print out the entire array in a human-readable format, making it easier to understand the array's structure and the values it contains. This can be particularly useful for debugging purposes or when trying to troubleshoot issues related to array manipulation.

<?php
// Sample array
$fruits = array("apple", "banana", "orange");

// Print out the array using print_r
print_r($fruits);
?>