Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I break an email address into different parts in php?

Tags:

javascript

php

Basically what I want to do is display an email using javascript to bring the parts together and form a complete email address that cannot be visible by email harvesters.

I would like to take an email address eg [email protected] and break it to: $variable1 = "info"; $variable2 = "thiscompany.com";

All this done in PHP.

Regards, JB

like image 708
Jay Bee Avatar asked Dec 12 '22 22:12

Jay Bee


2 Answers

list($variable1, $variable2) = explode('@','[email protected]');
like image 56
Brant Messenger Avatar answered Jan 17 '23 17:01

Brant Messenger


$parts = explode("@", $email_address);

Assuming that $email_address = '[email protected]' then $parts[0] == 'info' and $parts[1] == 'thiscompany.com'

like image 43
thetaiko Avatar answered Jan 17 '23 17:01

thetaiko