Saturday 28 July 2012

strstr() Function

Finds first occurance of any string from a given string.
strstr() function is a case sensitive function to use case insensitive stristr() is used.
e.g
$emailId = 'test@mydomain.com';
$domainName = strstr($emailId, '@');
echo $domainName; // outputp will be: mydomain.com
$firstPart = strstr($email, '@', true); // PHP 5.3 and above
echo $firstPart; // outputp will be: test
?>

No comments:

Post a Comment