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

文章参考

PHP之mb_stripos使用的更多相关文章

  1. php报错 Call to undefined function mb_stripos()

    错误原因 没有mbstring扩展 本文只介绍Linux解决办法 方法一 编译PHP的时候 带上--enable-mbstring参数 方法二 进入PHP源码/ext/mbstring目录 ./con ...

  2. php 基础代码大全(不断完善中)

    下面是基础的PHP的代码,不断完善中~ //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */ 常量名 类常量建议全大写,单词间用下划线 ...

  3. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

  4. 两千行PHP学习笔记

    亲们,如约而至的PHP笔记来啦~绝对干货! 以下为我以前学PHP时做的笔记,时不时的也会添加一些基础知识点进去,有时还翻出来查查. MySQL笔记:一千行MySQL学习笔记http://www.cnb ...

  5. php错误以及常用笔记

    //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */ 常量名 类常量建议全大写,单词间用下划线分隔 // MIN_WIDTH 变量名建 ...

  6. php 学习笔记

    //本文转自:http://www.cnblogs.com/ronghua/p/6002995.html //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. ...

  7. PHP编码相关函数试题

    1.检查字符串在指定的编码里是否有效的函数是什么? 2.获取字符编码的函数是什么? 3.解析 GET/POST/COOKIE 数据并设置全局变量的函数是什么? 4.大小写不敏感地查找字符串在另一个字符 ...

  8. PHP基础知识点

    //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */常量名 类常量建议全大写,单词间用下划线分隔 // MIN_WIDTH变量名建议用 ...

  9. 无格式转换php

    // 无格式转换function ClearHtml($content,$allowtags='') { mb_regex_encoding('UTF-8'); //replace MS specia ...

随机推荐

  1. Android-自定义开关(升级版)

    效果图: 定义一个类,取名为MySwitch.java,此类去继承View,为何是继承View而不是去继承ViewGroup呢,是因为自定义开关没有子控件,之需要操作自身绘制即可 package cu ...

  2. [LeetCode 题解]: Rotate List

    Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1 ...

  3. 生成Webservice的两种方式(Axis2,CXf2.x)

    一天之中,用了各种方式生成webservice,就是为了node.js能和程序顺利通信.最终还是用axis2成功了.工作基本完成了,现在可以总结一下. 关于生成方式,推荐使用eclipse,比较方便, ...

  4. Cockroachdb 二、手动部署

    二 集群手动部署 **需求** a 本地已安装CockroachDB b 可SSH访问每台机器,用于分发二进制文件和证书 c 端口 26257 用于集群内部通信及客户端访问连接HAProxy 8080 ...

  5. TSQL--使用CTE完成递归查询

    CREATE TABLE TB001( CategoryId INT PRIMARY KEY, ParentCategoryId INT, CategoryName NVARCHAR(200))GO ...

  6. .net core redis使用

    整理下.net core的redis使用  可以分布式 Nuget安装 StackExchange.Redis using System; using System.Collections.Gener ...

  7. Android 推送

    安卓推送方案及比较 http://www.eoe.cn/news/11955.html ******************************************************** ...

  8. mysql--mysql的安装与目录介绍

    一.mysql的下载安装 1.下载安装 1.windows10下安装 我们采用绿色免安装版, 打开你的mysql文件夹中的bin目录,我的是这个样子的 将这个路径添加入系统环境变量,首先右键此电脑-- ...

  9. “全栈2019”Java多线程第六章:中断线程interrupt()方法详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java多 ...

  10. ROS(URDF机器人建模)

    新建功能包mbot_description 在功能包下新建文件config,launch,meshes,urdf. 在launch文件夹下新建文件display_mbot_base_urdf.laun ...