• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • mb_stripos()

    (PHP 5 >= 5.2.0, PHP 7)

    大小写不敏感地查找字符串在另一个字符串中首次出现的位置

    说明

    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()查找字符串在另一个字符串中首次出现的位置
    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.

    上篇:mb_strimwidth()

    下篇:mb_stristr()