mb_stristr
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
mb_stristr — 大小寫不敏感地查詢字串在另一個字串里的首次出現
說明
mb_stristr(
string
string
bool
string
): string
string
$haystack
,string
$needle
,bool
$before_needle
= false,string
$encoding
= mb_internal_encoding()): string
mb_strstr() 查詢了 needle
在 haystack
中首次的出現並返回 haystack
的一部分。
和 mb_strstr() 不同的是,mb_stristr() 是大小寫不敏感的。
如果 needle
沒有找到,它將返回 false
。
參數
-
haystack
-
要獲取
needle
首次出現的字串。 -
needle
-
在
haystack
中查詢這個字串。 -
before_needle
-
決定這個函式返回
haystack
的哪一部分。 如果設定為true
,它返回haystack
中從開始到needle
出現位置的所有字元(不包括 needle)。 如果設定為false
,它返回haystack
中needle
出現位置到最後的所有字元(包括了 needle)。 -
encoding
-
要使用的字元編碼名稱。 如果省略該參數,將使用內部字元編碼。
返回值
返回 haystack
的一部分,或者 needle
沒找到則返回 false
。