How do I break email address into username and hostname?
If we assume that the email address is of this format:
username@hostname then this suggests a simple solution.
That is to split the string on the '@' character like in the following example:
<?php
$myemail = "dan@mysite.com";
$parts = explode("@",$myemail);
print_r($parts);
?>
This prints:
Array
(
[0] => dan
[1] => mysite.com
)
Comment on this Question and Answer >>>
ASK A QUESTION
More strings PHP Questions
How do I remove space from the start of a PHP string?How do I make the first letter of a string uppercase?
How do I calculate the metaphone of a string?
How do I one-way encrypt a string in PHP?
How do I find the length of a string in PHP?
