How can PHP developers ensure proper formatting and readability when outputting complex data structures like addresses in HTML or XML?

When outputting complex data structures like addresses in HTML or XML, PHP developers can ensure proper formatting and readability by using functions like `htmlspecialchars()` to escape special characters and maintain data integrity. Additionally, they can use formatting techniques such as indentation and line breaks to make the output more readable.

<?php
$address = [
    'street' => '123 Main St',
    'city' => 'City',
    'state' => 'State',
    'zip' => '12345'
];

echo '<address>';
echo '<strong>' . htmlspecialchars($address['street']) . '</strong><br>';
echo htmlspecialchars($address['city']) . ', ' . htmlspecialchars($address['state']) . ' ' . htmlspecialchars($address['zip']);
echo '</address>';
?>