iconv_strrpos()

iconv_strrpos() — Finds the last occurrence of a needle within a haystack.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

iconv_strrpos(string $haystack, string $needle, ?string $encoding = null): int|false

Parameters

ParameterTypeWhat it takes
$haystackstringThe entire string.
$needlestringThe searched substring.
$encoding?stringIf encoding parameter is omitted or null, string are assumed to be encoded in iconv.internal_encoding.

Return value

Returns the numeric position of the last occurrence of needle in haystack. If needle is not found, iconv_strrpos() will return false. This function may return Boolean false, but may also return a non-Boolean value which evaluates to false. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Example

The PHP manual ships no example for iconv_strrpos(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.0.0encoding is nullable now.

See also

strrpos(), iconv_strpos(), mb_strrpos()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page iconv_strrpos() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.