How can JSON data be formatted in PHP for better readability?

When outputting JSON data in PHP, it can sometimes be difficult to read and understand due to its compact format. To improve readability, you can use the `json_encode` function with the `JSON_PRETTY_PRINT` option. This will format the JSON data with proper indentation and line breaks, making it easier to read.

$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'email' => 'john.doe@example.com'
);

$json = json_encode($data, JSON_PRETTY_PRINT);
echo $json;