zoukankan      html  css  js  c++  java
  • PHP之mb_stripos使用

    mb_stripos

    • (PHP 5 >= 5.2.0, PHP 7)
    • mb_stripos — Finds position of first occurrence of a string within another, case insensitive
    • mb_stripos — 大小写不敏感地查找字符串在另一个字符串中首次出现的位置

    Description

    int mb_stripos ( 
        string $haystack , 
        string $needle [, 
        int $offset = 0 [, 
        string $encoding = mb_internal_encoding() ]] 
        )
    //mb_stripos() returns the numeric position of the first occurrence of needle in the haystack string. Unlike mb_strpos(), mb_stripos() is case-insensitive. If needle is not found, it returns FALSE.
    //mb_stripos() 返回 needle 在字符串 haystack 中首次出现位置的数值。 和 mb_strpos() 不同的是,mb_stripos() 是大小写不敏感的。 如果 needle 没找到,它将返回 FALSE。
    

    Parameters

    haystack

    • The string from which to get the position of the first occurrence of needle
    • 在这个字符串中查找获取 needle 首次出现的位置

    needle

    • The string to find in haystack
    • 在 haystack 中查找这个字符串

    offset

    • The position in haystack to start searching. A negative offset counts from the end of the string.
    • haystack 里开始搜索的位置。如果是负数,就从字符串的尾部开始统计。

    encoding

    • Character encoding name to use. If it is omitted, internal character encoding is used.
    • 使用的字符编码名称。 如果省略了它,将使用内部字符编码。

    Return Values

    • Return the numeric position of the first occurrence of needle in the haystack string, or FALSE if needle is not found.
    • 返回字符串 haystack 中 needle 首次出现位置的数值。 如果没有找到 needle,它将返回 FALSE。

    Example

    <?php
    /**
     * Created by PhpStorm.
     * User: zhangrongxiang
     * Date: 2018/2/3
     * Time: 下午3:47
     */
    
    $str = "PHP is the best language on the world!";
    echo mb_stripos( $str, "php" ) . PHP_EOL; //0
    echo mb_stripos( $str, "Best" ) . PHP_EOL; //11
    
    // !== 严格比较
    if ( mb_stripos( $str, "Php" ) !== false ) {
    	echo "exists" . PHP_EOL;
    	//php is the best language on the world!
    	echo mb_strtolower( $str ) . PHP_EOL;
    }
    
    echo mb_stripos( $str, "THE", 10 ) . PHP_EOL;//28
    
    

    文章参考

  • 相关阅读:
    70. Climbing Stairs(动态规划)
    53. Maximum Subarray(动态规划)
    PAT 1045. Favorite Color Stripe
    PAT 1044. Shopping in Mars
    分治策略
    时间复杂度和空间复杂度分析(转载)
    [转载]论坛中某位达人自己编写的Morlet连续小波变换程序
    连续小波时频图绘制原理    连续小波变换尺度与信号频率的关系
    Matlab中wavedec使用學習及詳解
    [转载]转载:小波分解层数与尺度的关系
  • 原文地址:https://www.cnblogs.com/zhangrxiang/p/8409732.html
Copyright © 2011-2022 走看看