What are some best practices for formatting and displaying array or session data in PHP for better readability?
When displaying array or session data in PHP, it's important to format it in a way that is easy to read and understand. One way to achieve this is by using the print_r() or var_dump() functions to display the data in a structured format. Additionally, you can use HTML formatting such as <pre> tags to preserve the formatting of the data when displayed on a webpage.
// Example of formatting and displaying array data using print_r()
$data = array('name' => 'John Doe', 'age' => 30, 'email' => 'johndoe@example.com');
echo '<pre>';
print_r($data);
echo '</pre>';
```
```php
// Example of formatting and displaying session data using var_dump()
session_start();
$_SESSION['user'] = array('name' => 'Jane Smith', 'age' => 25, 'email' => 'janesmith@example.com');
echo '<pre>';
var_dump($_SESSION['user']);
echo '</pre>';