mb_strstr

  • (PHP 5 >= 5.2.0, PHP 7)
  • mb_strstr — Finds first occurrence of a string within another
  • 查找字符串在另一个字符串里的首次出现

Description

string mb_strstr (
string $haystack ,
string $needle [,
bool $before_needle = false [,
string $encoding =mb_internal_encoding() ]]
) //mb_strstr() finds the first occurrence of needle in haystack and returns the portion of haystack. If needle is not found, it returns FALSE.
//mb_strstr() 查找了 needle 在 haystack 中首次的出现并返回 haystack 的一部分。 如果 needle 没有找到,它将返回 FALSE。

Parameters

haystack

  • The string from which to get the first occurrence of needle
  • 要获取 needle 首次出现的字符串。

needle

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

before_needle

  • Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the first occurrence of needle (excluding needle). If set to FALSE, it returns all of haystack from the first occurrence of needle to the end (including needle).
  • 决定这个函数返回 haystack 的哪一部分。 如果设置为 TRUE,它返回 haystack 中从开始到 needle 出现位置的所有字符(不包括 needle)。 如果设置为 FALSE,它返回 haystack 中 needle 出现位置到最后的所有字符(包括了 needle)。

encoding

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

Return Values

  • Returns the portion of haystack, or FALSE if needle is not found.
  • 返回 haystack 的一部分,或者 needle 没找到则返回 FALSE。

Examples

<?php
/**
* Created by PhpStorm.
* User: zhangrongxiang
* Date: 2018/2/1
* Time: 下午10:27
*/ //* * If set to true, it returns all of haystack from the beginning to the first occurrence of needle.
$strstr = mb_strstr( "hello china", "ll", true );
echo $strstr . PHP_EOL; //he //* If set to false, it returns all of haystack from the first occurrence of needle to the end,
$strstr = mb_strstr( "hello china", "ll", false );
echo $strstr . PHP_EOL;//llo china //hello china
echo mb_strstr( "hello china", "ll", true ) . mb_strstr( "hello china", "ll", false ) . PHP_EOL; $strstr = mb_strstr( "hello China,hello PHP", "ll", true );
echo $strstr . PHP_EOL; //he $strstr = mb_strstr( "hello China,hello PHP", "ll", false );
echo $strstr . PHP_EOL; //llo China,hello PHP $strstr = mb_strstr( "PHP是世界上最好的语言

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

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

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

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

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

  3. PHP字符串处理

    /*1 字符串格式化 */ $str = ' php '; //清理两边的空格trim();,左边ltrim(); 边rtrin() echo trim($str); //nl2br();将换行符\n ...

  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 - 字符串操作

    第8章 字符串处理 学习要点: 1.字符串格式化 2.操作子字符串 3.字符串比较 4.查找替换字符串 5.处理中文字符 在每天的编程工作中,处理.调整以至最后控制字符串是很重要的一部分,一般也认为这 ...

  8. PHP基础知识点

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

  9. PHP类和函数注释大全

    每次要用PHP的某个功能的时候,都要去查一下,于是决定将PHP所有类和函数都整理出来,加上注释 大致实现 将php.jar文件解压,取出目录stubs 将stubs中的所有php文件中的注释去掉,并做 ...

随机推荐

  1. FORM 错误:此责任无可用函数。 更改责任或与您的系统管理员联系。

    错误:此责任无可用函数. 更改责任或与您的系统管理员联系. 2014-07-02 12:20:47 分类: Oracle Symptom 访问Help->Diagnostics->Exam ...

  2. IPv4&&IPv6地址结构分析

    IPv4套接字地址结构: 套接字都需要有一个指向套接字地址结构的指针作为参数.每个协议簇都定义它自己的套接字地址结构.这些结构的名字均已sockaddr_开头,并以对应每个协议族的唯一后缀结尾. wi ...

  3. xml与json的区别和总结

    JSON和XML的比较 ◆可读性 JSON和XML的可读性可谓不相上下,一边是简易的语法,一边是规范的标签形式,很难分出胜负. ◆可扩展性 XML天生有很好的扩展性,JSON当然也有,没有什么是XML ...

  4. 用.msi安装node时安装失败,出现rolling back action(转载)

    转载地址:https://blog.csdn.net/qq_33295622/article/details/52956369在重装node时出现了上图所示情况,解决方法如下: 1.在官网下载稳定版本 ...

  5. [UWP开发]在windows10中设置壁纸~UserProfilePersonalizationSettings

    在之前的wp8.1和wp8中,微软没有公开设置壁纸的API,只有一个设置锁屏的API,但在Windows10中,微软为我们提供了设置壁纸的API:TrySetWallpaperImageAsync,他 ...

  6. mylyn提交到JIRA的日期格式错误

    HTTP Status 400 - Date value '27/Dec/11' for field 'due' is invalid. Valid formats include: 'yyyy/MM ...

  7. lucene3.0_IndexSearcher排序

    系列汇总: lucene3.0_基础使用及注意事项汇总 IndexSearcher排序 本文主要讲解: 1.IndexSearcher中和排序相关的方法及sort类.SortField类(api级别) ...

  8. httpclient4.5 https请求 忽略身份验证

    import org.apache.commons.collections.MapUtils; import org.apache.http.*; import org.apache.http.cli ...

  9. js判断手机端操作系统的两种方法

    //判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面 androidURL ="http://xxx/xxx.apk"; var browser = { ver ...

  10. 十招谷歌 Google 搜索

    十招谷歌搜索 一.或者 OR 二.网址 insite:example.com keyword 三.大约 1.类似查询(记得) ~keyword 2.模糊查询(记得) key*****word 3.模糊 ...