What are some recommended PHP functions for string manipulation when extracting data from emails?

When extracting data from emails, it is common to need to manipulate strings to extract specific information such as email addresses, names, or other details. PHP offers a variety of built-in functions for string manipulation that can be useful in this scenario. Some recommended PHP functions for string manipulation when extracting data from emails include `preg_match()`, `explode()`, `substr()`, `str_replace()`, and `trim()`.

// Example of using PHP functions for string manipulation when extracting data from emails

$email = "john.doe@example.com";
$name = substr($email, 0, strpos($email, "@")); // Extracting name before the @ symbol
$domain = substr($email, strpos($email, "@") + 1); // Extracting domain after the @ symbol
$cleanedEmail = str_replace(".", "", $email); // Removing dots from the email address
$trimmedEmail = trim($email); // Removing any leading or trailing spaces

echo "Name: " . $name . "\n";
echo "Domain: " . $domain . "\n";
echo "Cleaned Email: " . $cleanedEmail . "\n";
echo "Trimmed Email: " . $trimmedEmail . "\n";