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. SQL 增加列

    -- 判断是否存在该列 if exists(SELECT * FROM syscolumns WHERE id=object_id('@Table') and name='@COLUMN') ALTE ...

  2. windows下用wampServer 为wordpress 搭建本地服务器运行环境

      1.准备wamp server wamp是windows apache mysql php 的首字母缩写,更新的wamp总能保证wordpress对服务器的要求 点此下载最新wamp 2.安装wa ...

  3. C/C++,python,java,C#月经贴问题

    在刚开始的时候,一直纠结于语言之争,什么什么有前途,什么什么没前途.对于什么的支持不好啦,个人信仰问题啦.什么都有. 首先最主要的一个个人观点:“语言不是老婆,不是一夫一妻制”.你可以同时拥有许多的女 ...

  4. Logstash配置总结和实例

    这里记录Logstash配置中注意的事项: 整个配置文件分为三部分:input,filter,output.参考这里的介绍 https://www.elastic.co/guide/en/logsta ...

  5. ZooKeeper学习2---ZooKeeper安装配置

    一.Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式. ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境:■ 伪集群模式:就是在一台物 ...

  6. [iOS笔试600题]一、语法篇(共有147题)

    [A]1. @property 的作用是申明属性及真特性?[判断题] A.正确 B.错误 [A]2. @synthesize的作用是自动笠成属性的访问器(getter/setter)方法?[判断题] ...

  7. python-----读写操作

    1. 文件的读取 注意:在windows中文件的路径是这样:C:\Users\name\mystuff .由于\u在python中表示转义如果使用此文件路径就会报错.解决方法: a.把斜杠\改为反斜杠 ...

  8. Python中的匿名函数lambda的用法

    一.lambda函数的简介  对lambda函数,它其实是一个类似于def的函数,只不过lambda是一个不需要定义函数名的匿名函数.当我们在有些时候,需要做一些简单的数学计算时,如果定义一个def函 ...

  9. InfluxDB概念和基本操作 二

    InfluxDB概念和基本操作   InfluxDB基本概念 数据格式 在 InfluxDB 中,我们可以粗略的将要存入的一条数据看作一个虚拟的 key 和其对应的 value(field value ...

  10. CentOS 7 安装程序介绍

    (一).引导菜单 使用 UEFI 引导 Install CentOS Linux 7 选择此选项开始在你的计算机系统中使用图形安装程序安装 CentOS 7 Test this media & ...