mb_stripos
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
mb_stripos — 大小写不敏感地查找字符串在另一个字符串中首次出现的位置
说明
mb_stripos(
string
string
int
string
): int
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 使用负数。
|

User Contributed Notes 1 note
FangTS_ ¶
2 years ago
How works on examples mb_stripos:
First we will watch example on symbols(..?).
<?php
$text = "Look! It's a text! Wow!"; //simple text
$spaceIsHere = mb_stripos($text," "); //you can replace " " on something what you need or want
$text2 = mb_substr($text,$spaceIsHere); //cutting text with $spaceIsHere
print ($text2);
/* Print will show that result:
" It's a text! Wow!"
Look. That " " wasn't cutted, because mb_substr don't write in var position after " " - he write WHERE is " " in string. */
?>
Also it can work on words, sentences...
Here's one of examples:
<?php
$text = "Look! It's a text! Wow!"; //familiar text, right?)
$afterNeededWord = mb_stripos($text,"text!"); //you can replace "text!" on something else what you need
$text3 = mb_substr($text, $afterNeededWord); //cutting string (it is string? im stupid in that question xD)
print ($text3);
/* Print will show that result:
"text! Wow!"
Explaining the same. */
?>
I hope it was useful with my "good" English skills. ;D
Have a nice day, coder.