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
文章参考
PHP之mb_stripos使用的更多相关文章
- php报错 Call to undefined function mb_stripos()
错误原因 没有mbstring扩展 本文只介绍Linux解决办法 方法一 编译PHP的时候 带上--enable-mbstring参数 方法二 进入PHP源码/ext/mbstring目录 ./con ...
- php 基础代码大全(不断完善中)
下面是基础的PHP的代码,不断完善中~ //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */ 常量名 类常量建议全大写,单词间用下划线 ...
- PHP7函数大全(4553个函数)
转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...
- 两千行PHP学习笔记
亲们,如约而至的PHP笔记来啦~绝对干货! 以下为我以前学PHP时做的笔记,时不时的也会添加一些基础知识点进去,有时还翻出来查查. MySQL笔记:一千行MySQL学习笔记http://www.cnb ...
- php错误以及常用笔记
//语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */ 常量名 类常量建议全大写,单词间用下划线分隔 // MIN_WIDTH 变量名建 ...
- php 学习笔记
//本文转自:http://www.cnblogs.com/ronghua/p/6002995.html //语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. ...
- PHP编码相关函数试题
1.检查字符串在指定的编码里是否有效的函数是什么? 2.获取字符编码的函数是什么? 3.解析 GET/POST/COOKIE 数据并设置全局变量的函数是什么? 4.大小写不敏感地查找字符串在另一个字符 ...
- PHP基础知识点
//语法错误(syntax error)在语法分析阶段,源代码并未被执行,故不会有任何输出. /* [命名规则] */常量名 类常量建议全大写,单词间用下划线分隔 // MIN_WIDTH变量名建议用 ...
- 无格式转换php
// 无格式转换function ClearHtml($content,$allowtags='') { mb_regex_encoding('UTF-8'); //replace MS specia ...
随机推荐
- iOS9 Https技术预研
一.服务器需要做的事情: 1.要注意 App Transport Security 要求 TLS 1.2, 2.而且它要求站点使用支持forward secrecy协议的密码. 3.证书也要求是符合A ...
- EBS 并发程序运行信息
--并发程序运行信息SELECT REQUEST_ID, PROGRAM, actual_start_date 开始日期, ACTUAL_COMPLETION_DA ...
- Tomcat不自动解压问题
问题: 版本迭代上线,需要更换新的war包, 1.先将老的war和文件夹删除掉,再放入新的war到webapps中, 2.发现启动Tomcat后没有解压该war包, 3.需要先将server.xml中 ...
- WPF Path 画箭头
代码: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.c ...
- Android移动客户端性能测试浅谈——电量
本文由作者张迎贞授权网易云社区发布. APP性能测试除了需要监控PCU.内存占用.流量等,还需要获取APP的电量数据,测试在可接受范围内,避免APP出现过度消耗电量的现象.手机有很多硬件模块:CPU, ...
- iOS 优秀开源项目
1. 界面 iCarousel: 用来做图片旋转显示效果(相册). MZTimerLabel:用来制作一个计时并显示时间的 label. MSDynamicsDrawerViewController, ...
- 【QT】二进制读取图像文件并显示
打开对话框选择文件 二进制方式读取文件 转换成图像显示 void MainWindow::showImage() { //打开文件对话框 QString lastPath="D:/Engli ...
- 【ocp-12c】最新Oracle OCP-071考试题库(43题)
43.(9-2)choose three Which three tasks can be performed by DDL statements? A) preventing data retrie ...
- [Objective-C语言教程]指针(15)
Objective-C中的指针简单易学.使用指针可以更轻松地执行某些Objective-C编程任务,并且在不使用指针的情况下无法执行其他任务(如动态内存分配). 所以有必要学习指向成为一个完美的Obj ...
- [Swift实际操作]七、常见概念-(14)使用UIColor设置界面组件的颜色属性
打开移动应用程序,不可避免的需要和颜色打交道.本文将为你演示颜色对象的使用. 首先导入需要使用到的界面工具框架 import UIKit 通过UIColor的属性,可以获得橙色.右侧的实时反馈区,显示 ...