iconv_strrpos
Description
The iconv_strrpos of iconv for PHP finds the last occurrence of a needle within a haystack.
Syntax
iconv_strrpos( string $haystack, string $needle, ?string $encoding = null ): int|false
Parameters
haystack
The entire string.
If it is not a string, it is converted to a string and applied as the ordinal value of a character.
needle
The searched substring.
If it is not a string, it is converted to a string and applied as the ordinal value of a character.
encoding
If encoding parameter is omitted or null, string are assumed to be encoded in iconv.internal_encoding.
Return
Returns the numeric position of the last occurrence of needle in haystack, false if the needle is not found.
WARNING: 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.
Examples
1 · haystack needle
<? $haystack = "haystack·haystack·haystack"; $needle = "·"; $return = iconv_strrpos($haystack, $needle); echo $return;
17
2 · encoding
<? $haystack = "haystack·haystack·haystack"; $needle = "·"; $encoding = "ISO-8859-1"; $return = iconv_strrpos($haystack, $needle, $encoding); echo $return;
18