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

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 "?



Custom Search