mb_stripos()
mb_stripos() — Finds position of first occurrence of a string within another, case insensitive.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
mb_stripos() returns the numeric position of the first occurrence of needle in the haystack string. Unlike mb_strpos(), mb_stripos() is case-insensitive. If needle is not found, it returns false.
Signature
mb_stripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $haystack | string | The string from which to get the position of the first occurrence of needle |
| $needle | string | The string to find in haystack |
| $offset | int | The position in haystack to start searching. A negative offset counts from the end of the string. |
| $encoding | ?string | The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used. |
Return value
Return the numeric position of the first occurrence of needle in the haystack string, or false if needle is not found.
Example
The PHP manual ships no example for mb_stripos(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.0.0 | needle now accepts an empty string. |
| 8.0.0 | encoding is nullable now. |
| 8.0.0 | Now throws a ValueError if encoding is an invalid encoding. Previously, an E_WARNING was emitted and false was returned. |
| 7.1.0 | Support for negative offsets has been added. |
See also
stripos(), strpos(), mb_strpos()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_stripos() (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.