大小寫不敏感地查詢字串在另一個字串中首次出現的位置

mb_stripos

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

mb_stripos — 大小寫不敏感地查詢字串在另一個字串中首次出現的位置

說明

mb_stripos(
    string $haystack,
    string $needle,
    int $offset = 0,
    string $encoding = mb_internal_encoding()
): int

mb_stripos() 返回 needle 在字串 haystack 中首次出現位置的數值。 和 mb_strpos() 不同的是,mb_stripos() 是大小寫不敏感的。 如果 needle 沒找到,它將返回 false。

參數

haystack

在這個字串中查詢獲取 needle 首次出現的位置

needle

在 haystack 中查詢這個字串

offset

haystack 里開始搜索的位置。如果是負數,就從字串的尾部開始統計。

encoding

使用的字元編碼名稱。 如果省略了它,將使用內部字元編碼。

返回值

返回字串 haystack 中 needle 首次出現位置的數值。 如果沒有找到 needle,它將返回 false。

更新日誌

版本說明
7.1.0 支援 offset 使用負數。

參見

  • stripos() - 查詢字串首次出現的位置(不區分大小寫)
  • strpos() - 查詢字串首次出現的位置
  • mb_strpos() - 查詢字串在另一個字串中首次出現的位置

Leave a Reply

Your email address will not be published. Required fields are marked *