How to use php strstr function

青灯夜游
Release: 2023-02-22 19:48:01
Original
4738 people have browsed it

The strstr() function is a built-in function in PHP. The syntax is strstr(string,search,before_search). It is used to search whether a string exists in another string. If so, return the string and the remaining part. , otherwise return FALSE. This function is case-sensitive.

How to use php strstr function

php How to use strstr() function?

strstr() function searches whether a string exists in another string. If so, returns the string and the remaining parts, otherwise returns FALSE.

Note: This function is binary safe; this function is case-sensitive.

Syntax

strstr(string,search,before_search)
Copy after login

Parameters: The function accepts three parameters, as shown in the above syntax, of which the first two must be provided parameters, the third parameter is optional.

● 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. A Boolean value with a default value of "false". If set to "true", it returns the portion of the string preceding the first occurrence of the search parameter.

Return value: This function returns the rest of the string (from the matching point), or FALSE if the string being searched is not found.

Let’s take a look at how to use the php strstr() function through an example.

Example 1:

Copy after login

Output:

o world!
Copy after login

Example 2:

Copy after login

Output:

Hell
Copy after login

The above is the detailed content of How to use php strstr function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!