PHP stristr function returns a string from the beginning to the end of another string. It is not case-sensitive. Its syntax is stristr(string,search,before_search). The parameter string is required and specifies what is to be searched. String; required for search, specifies the string to be searched.
How to use php stristr function?
php stristr() function syntax
Function: Returns a string from the beginning to the end of another string, case-insensitive
Syntax:
stristr(string,search,before_search)
Parameters:
string required. Specifies the string to be searched for.
search Required. Specifies the string to search for. If the argument is a number, searches for characters that match the ASCII value for that number.
before_search Optional. The default value is a Boolean value of "false". If set to "true", it returns the portion of the string preceding the first occurrence of the search parameter.
Description:
Search for the first occurrence of a string in another string. This function is binary safe. This function is not case sensitive. For case-sensitive searches, use the strstr() function.
php stristr() function usage example 1:
<?php echo stristr("Hello php.cn!","php"); ?>
Output:
php.cn!
php stristr() function usage example 2:
<?php echo stristr("i study php in php.cn!","study"); ?>
Output:
study php in php.cn!
This article is an introduction to the PHP stristr function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use php stristr function. For more information, please follow other related articles on the PHP Chinese website!