PHP strstr function
The PHP strstr function can be used to determine the first occurrence of a character in a string and output the string after the key character, and the output string contains the key character. The strstr function will automatically determine the English The case of letters, if you want to have the judgment effect of "not distinguishing the case of English letters", you can use the similar stristr function to handle it. In addition, if you just want to determine whether a certain character or letter is in the string, you can use a relatively fast and low memory usage strpos function . Please look at the usage of PHP strstr function.
PHP strstr function syntax
string strstr (string $haystack, $needle, bool $before_needle)
The first parameter of the PHP strstr function, $haystack, can be said to be the original string being queried, which is a required item. The second parameter, $needle, is the character to be compared and is a required item. If $needle is a number, it will be converted to a corresponding decimal ASCII character, and then the content of the $haystack string will be compared. The third parameter $before_needle is a new parameter in PHP 5.3.0. The default value is false and is not a required item. If it is set to true, all strings before $needle appear in the $haystack string will be output, and no Contains $needle.
PHP strstr function example
$UserEmail ='someone@wibibi.com';
$EmailDomain = strstr($UserEmail,'@');
echo $EmailDomain.'<br>';
$UserName = strstr($UserEmail,'@',true );
echo $UserName;
?>
someone
Post a Comment
0 Comments