Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_strripos

Description

Finds position of last occurrence of a string within another, case insensitive

Syntax

mb_strripos(
    string $haystack,
    string $needle,
    int $offset = 0,
    ?string $encoding = null
): int|false

Parameters

haystack

The string from which to get the position of the last occurrence of needle

needle

The string to find in haystack

offset

The position in haystack to start searching

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return

Return the numeric position of the last occurrence of needle in the haystack string, or false if needle is not found.

Examples

1 · haystack needle

<?

$haystack = 'string🐘string🐘string';
$needle = '🐘STRING';

$return = mb_strripos($haystack, $needle);

echo $return;

?>
13

2 · offset · negative

<?

$haystack = 'string🐘string🐘string';
$needle = '🐘STRING';
$offset = -10;

$return = mb_strripos($haystack, $needle, $offset);

echo $return;

?>
6

3 · offset · non-negative

<?

$haystack = 'string🐘string🐘string';
$needle = '🐘STRING';
$offset = 10;

$return = mb_strripos($haystack, $needle, $offset);

echo $return;

?>
13

4 · encoding

<?

$haystack = 'string🐘string🐘string';
$needle = '🐘STRING';
$offset = 10;
$encoding = 'UTF-8';

$return = mb_strripos($haystack, $needle, $offset, $encoding);

echo $return;

?>
13
HomeMenu