Home > Backend Development > PHP Problem > How to use php stripos function?

How to use php stripos function?

青灯夜游
Release: 2023-02-22 22:52:01
Original
2652 people have browsed it

php stripos() function is used to find the first occurrence of a string in another string (not case-sensitive). The syntax is stripos(string,find,start). If the string is not found, it will be returned. FALSE.

How to use php stripos function?

How to use the php stripos() function?

The stripos() function finds the first occurrence of a string in another string (case-insensitive).

Syntax:

stripos(string,find,start)
Copy after login

Parameters:

● string: required. Specifies the string to search for.

● find: required. Specifies the characters to search for.

● start: optional. Specifies the location from which to start the search.

Return value: Returns the position of the first occurrence of a string in another string, or returns FALSE if the string is not found.

Note: stripos() function is case-insensitive; this function is binary safe. String positions start at 0, not 1.

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

Example 1:

<?php
echo stripos("You love php, I love php too!","PHP")
?>
Copy after login

Output:

9
Copy after login

Example 2:

<?php
echo stripos("PHP is a good development language!","php");
?>
Copy after login

Output:

0
Copy after login

The above is the detailed content of How to use php stripos 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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template