How to use php stristr function

藏色散人
Release: 2023-04-05 06:26:01
Original
3210 people have browsed it

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)
Copy after login

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");
?>
Copy after login

Output:

php.cn!
Copy after login

php stristr() function usage example 2:

<?php
echo stristr("i study php in php.cn!","study");
?>
Copy after login

Output:

study php in php.cn!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template