Home  >  Article  >  Backend Development  >  How to use php stristr function

How to use php stristr function

藏色散人
藏色散人Original
2019-02-01 11:11:573183browse

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

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn