php学习笔记之mb_strstr的基本使用
前言
本文主要介绍了关于php之mb_strstr基本使用的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
mb_strstr
- (PHP5>=5.2.0,PHP7)
- mb_strstr—Findsfirstoccurrenceofastringwithinanother
- 查找字符串在另一个字符串里的首次出现
Description
stringmb_strstr( string$haystack, string$needle[, bool$before_needle=false[, string$encoding=mb_internal_encoding()]] ) //mb_strstr()findsthefirstoccurrenceofneedleinhaystackandreturnstheportionofhaystack.Ifneedleisnotfound,itreturnsFALSE. //mb_strstr()查找了needle在haystack中首次的出现并返回haystack的一部分。如果needle没有找到,它将返回FALSE。
Parameters
haystack
- Thestringfromwhichtogetthefirstoccurrenceofneedle
- 要获取needle首次出现的字符串。
needle
- Thestringtofindinhaystack
- 在haystack中查找这个字符串。
before_needle
- Determineswhichportionofhaystackthisfunctionreturns.IfsettoTRUE,itreturnsallofhaystackfromthebeginningtothefirstoccurrenceofneedle(excludingneedle).IfsettoFALSE,itreturnsallofhaystackfromthefirstoccurrenceofneedletotheend(includingneedle).
- 决定这个函数返回haystack的哪一部分。如果设置为TRUE,它返回haystack中从开始到needle出现位置的所有字符(不包括needle)。如果设置为FALSE,它返回haystack中needle出现位置到最后的所有字符(包括了needle)。
encoding
- Characterencodingnametouse.Ifitisomitted,internalcharacterencodingisused.
- 要使用的字符编码名称。如果省略该参数,将使用内部字符编码。
ReturnValues
- Returnstheportionofhaystack,orFALSEifneedleisnotfound.
- 返回haystack的一部分,或者needle没找到则返回FALSE。
Examples