Split email id from username using strstr

author details
AdiPie
5th Aug 2020
1 min read
Image
strstr_using_emailid

strstr() isn't an approach to maintain a strategic distance from type-checking with strpos(). 

strstr - Find the first occurrence of a string

$email = 'username@email.com';

$username = strstr($email, '@', true); //"username"

Additionally, strstr() is definitely more memory-serious than strpos(), so in the event that you are not keen on the substring that strstr() returns, you shouldn't utilize it at any rate. 

My recommendation is to begin adoring sort checking quickly, and to acquaint yourself with the arrival estimation of the capacities you are utilizing.