Backend Development 2 min read

PHP strrpos() Function – Description, Parameters, Return Value, and Examples

The article explains PHP's strrpos() function, detailing its signature, how it finds the last occurrence of a needle in a haystack string, the meaning of its parameters and offset, the return values, and provides multiple code examples illustrating typical usage.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP strrpos() Function – Description, Parameters, Return Value, and Examples

strrpos() calculates the position of the last occurrence of a needle string within a haystack string.

Signature:

int strrpos ( string $haystack , string $needle [, int $offset = 0] )

Description: Returns the numeric position of the last occurrence of $needle in $haystack . In PHP 4, $needle must be a single character; if a string is given, only its first character is used.

Parameters:

$haystack – the string to search in.

$needle – the string to search for; if not a string it is converted to an integer character code.

$offset – optional offset; negative values start counting from the end of the string.

Return value: The position of $needle if found, otherwise FALSE .

Examples:

backendProgrammingphpstring-functionsstrrpos
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.