Question

i have a login form, where the user must type in his e-mail address. Now i want to cut off the @ and the e-mail domain and save this as username.

For example:

$email = $_POST['email'];
//$email = muster.hans@gmail.com

now the username should be:

muser.hans
Was it helpful?

Solution

Use strstr()

echo strstr( $_POST['email'],'@',true);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top