PHP stristr function
The PHP stristr function can determine the position of the special character in the string for the first time, and output the key characters and other strings on the web page. The usage is the same as the strstr function , but the difference is that the strist function will size the English letters Writing is considered the same, and the strstr function treats letter case as different.
Basic syntax of PHP stristr function
string stristr ( string $haystack , $needle , bool $before_needle )
The first parameter $haystack of the stristr function is the original string to be queried, and the second parameter $needle is the self-defined key character. The stristr function will automatically determine whether there is a $needle character in the $haystack string , If any, return the string containing the $needle character and other characters after it. These two parameters are required items. If stristr does not find any key characters in the original string, it will return false. The last parameter is a new parameter after PHP 5.3.0, optional item, default is false, if set to true, the stristr function finds a key character in the original string and returns the string before the character , And does not contain key characters.
PS.$needle parameters can also use numbers, the stristr function will convert them into the corresponding decimal ASCII characters.
PHP stristr function example 1
$ UserEmail = 'someone@wibibi.com';
echo stristr ($ UserEmail, 'E');
echo stristr ($ UserEmail, 'E', true);
?>
som
PHP stristr function example 2
$UserEmail = 'someone@wibibi.com';
echo stristr($UserEmail, 101).<br>;
echo stristr($UserEmail, 69);
?>
eone@wibibi.com
PHP stristr function example three
$UserEmail ='someone@wibibi.com';
if(stristr($UserEmail,'z')===FALSE){ echo'The
English letter z is not in the original string';
}
?>
Post a Comment
0 Comments