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

How to use php stripos function?

青灯夜游
青灯夜游Original
2019-05-30 13:26:002669browse

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)

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")
?>

Output:

9

Example 2:

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

Output:

0

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!

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