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
I retrieve data from a Mysql database and insert it into a textfield form. The data that I retrieve have a / at the end of the string. The data in the database does not have this / in the data. How do I remove this /?How do I count the number of words in my text?
How do I count how many times each character occurs in a string?
7 Using regular expressions check for the validity of entered email-id. The @ symbol should not appear more than once. The dot (.) can appear at the most once before @ and at the most twice or at least once after @ symbol. The substring before @
How do I make the contents of a string upper case?
