How to select characters before @ in emails for PHP?
character, email, php, symbols
Solution
PHP has a lot of string funcitons... and strstr is what you want.
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com
$user = strstr($email, '@', true); // As of PHP 5.3.0
echo $user; // prints name
Problem
I'm a newbie in PHP. I need help selecting only characters before the symbol '@' in email addresses in PHP. For example; My email is test@example.com. I only want to return the value 'test', which is characters before the symbol '@'. I guess this is just a simple question, but I have no idea how to do it. Help! Thanks in advance.