PHP strrpos()Function

PHP String 参考手册PHP String Reference Manual

Examples

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

<?php
echo strrpos("I love php, I love php too!","php");
?>

Run Example »

Definition and Usage

The strrpos() function finds the last occurrence of a string in another string (case-sensitive).

Note:The strrpos() function is case-sensitive.

Related functions:

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

Syntax

strrpos(string,find,start)

Parameter Description
string Required. Specifies the string to be searched.
find Required. Specifies the character to find.
start Optional. Specifies the position to start the search.

Technical Details

Return Value: Returns the position of the last occurrence of the string in another string, or returns FALSE if the string is not found.Note:String positions start at 0, not at 1.
PHP Version: 4+
Changelog: Since PHP 5.0,findthe parameter can be a string of more than one character.

In PHP 5.0, thestartparameter was added.


PHP String 参考手册PHP String Reference Manual Other Extensions