Home > Backend Development > PHP Tutorial > PHP function strripos() to find the last occurrence of a string in another string (case insensitive)

PHP function strripos() to find the last occurrence of a string in another string (case insensitive)

黄舟
Release: 2023-03-17 06:52:02
Original
1649 people have browsed it

Example

Find the last occurrence of "php" in a string:

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

Definition and usage

strripos() function finds the last occurrence of a string in another string The position of the last occurrence in the string (case-insensitive).

Note: The strripos() function is not case-sensitive.

Related functions:

  • stripos() - Find the first occurrence of a string in another string (case-insensitive)

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

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

Syntax

strripos(string,find,start)
Copy after login
Parameters Description
stringRequired. Specifies the string to be searched for.
findRequired. Specifies the characters to search for.
startOptional. Specifies the location to start the search.

Technical details

Return value: Returns a string within another string The position of the last occurrence, or FALSE if the string is not found. Note: The string position starts from 0, not from 1.
PHP version: 5+
Change log: Since PHP 5.0, find The argument can be a string of more than one character.

In PHP 5.0, the start parameter is added.

Example

Find the last occurrence of "java" in the string:

<?php
echo strripos("what is java and what is php?","java");
?>
Copy after login


The above is the detailed content of PHP function strripos() to find the last occurrence of a string in another string (case insensitive). 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