Home  >  Article  >  Backend Development  >  Definition and usage of php string function stripos()

Definition and usage of php string function stripos()

怪我咯
怪我咯Original
2017-06-08 15:49:518519browse

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)

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

Parameter Description
string Required . Specifies the string to be searched for.
find Required. Specifies the characters to search for.
start Optional. 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;
?>

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!

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