In PHP, what methods can be used to manipulate strings and format output, such as adding spaces and special characters like brackets, for email subjects or messages?

When manipulating strings in PHP for email subjects or messages, you can use functions like `str_pad()` to add spaces, `str_replace()` to add special characters like brackets, and `htmlspecialchars()` to escape special characters for safe output. These functions help format the strings as needed for email subjects or messages.

// Example of manipulating strings for email subjects or messages
$emailSubject = "Important Notification";
$emailSubject = str_pad($emailSubject, 30, " ", STR_PAD_BOTH); // Add spaces to center the subject
$emailSubject = str_replace("Notification", "[Notification]", $emailSubject); // Add brackets around a specific word
$emailSubject = htmlspecialchars($emailSubject); // Escape special characters for safe output
echo $emailSubject;