Hi want to change the displayed username like abcd@somedomain.com to only abcd. so for this i should clip the part starting from @.
I can do this very easily through
Try this:
$username = substr($username, 0, strpos($username, '@'));
Use strstr function.
An example from the PHP reference -
<?php
$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
?>
$crop_username = substr($username, 0, strpos($username, '@'));
This will help you
substr(string, 0, 20)
String, start, length
list($username, $domain) = explode('@', 'asdf@somedomain.com')
Use strtok().
$username = strtok($email, '@');
CodePad.