PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I break email address into username and hostname?


The key to understanding the format of an email address is that there will be something followed by the '@' symbol and then followed by something else.

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?



Custom Search