Definition and usage of php string function stripos()

怪我咯
Release: 2023-03-08 06:42:01
Original
8580 people have browsed it

The string function stripos() is to find the position where a string appears for the first time in another string. This function is not case-sensitive and is very convenient to use. The following article will take you through PHP stripos() in detail and introduce its usage.

Definition and usage of php string function stripos()

#php What is the role of string function stripos()?

The string function stripos() is to find the first occurrence of a string in another string. This function is not case-sensitive. It is very convenient to use, and its related functions are

  • strripos() - Find the last occurrence of a string in another string (not Case sensitive)

  • strpos() - Find the first occurrence of a string in another string (case sensitive)

  • strrpos() - Find the last occurrence of a string in another string (case sensitive)

Below Let’s take a look at the syntax of the stripos() function

stripos(string,find,start)
Copy after login

This function has three parameters, the first two parameters are required, and the third parameter is optional

Parameter Description
stringRequired . Specifies the string to be searched for.
findRequired. Specifies the characters to search for.
startOptional. Specifies the location from which to start the search.

The return value of the stripos() function

stripos() function returns the first string in another string The position where the string appears, or FALSE if the string is not found. String positions start at 0, not 1.

Let’s take a look at an example of the stripos() function. The code is as follows

<?php
$a="I love php,I love php too!";
$c=stripos($a,"PHP");
echo $c;
?>
Copy after login

The code running result:

Definition and usage of php string function stripos()

【Recommended related articles】

php strpos() function example detailed explanation

php string function Detailed explanation of strripos() example

Detailed explanation of string function strrpos()

The above is the detailed content of Definition and usage of php string function stripos(). 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