95 of 410 menu

The mb_stripos Function

The mb_stripos function finds the first occurrence of a substring in a string, ignoring character case. Unlike stripos, it works correctly with multibyte encodings (UTF-8 and others). Its first parameter is the string to search in, the second is the substring to find, the third (optional) is the starting position for the search, and the fourth is the encoding.

Syntax

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

Example

Find the position of a substring in a string:

<?php $res = mb_stripos('AbCdE', 'bc'); echo $res; ?>

Code execution result:

1

Example

Search with a specified starting position:

<?php $res = mb_stripos('AbCdE', 'cd', 2); echo $res; ?>

Code execution result:

2

Example

Search with encoding specified:

<?php $res = mb_stripos('Привет мир', 'МИР', 0, 'UTF-8'); echo $res; ?>

Code execution result:

7

See Also

  • the mb_strpos function,
    which performs a case-sensitive search
  • the stripos function,
    which works similarly but without multibyte encoding support
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline