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 turn a string into an array?How do I display newline characters on a webpage?
How do I one-way encrypt a string in PHP?
how to compare strings in PHP?
What is the difference between ' and "?
