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

mb_stripos

Description

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

Syntax

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

Parameters

haystack

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

needle

The string to find in haystack

offset

The position in haystack to start searching. A negative offset counts from the end of the string.

encoding

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

Return

Return the numeric position of the first 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_stripos($haystack, $needle);

echo $return;

?>
6

2 · offset · negative

<?

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

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

echo $return;

?>
13

3 · offset · non-negative

<?

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

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

echo $return;

?>
13

4 · encoding

<?

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

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

echo $return;

?>
13
HomeMenu