strpos() 函数

语法:

mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )

查找 needle 在 haystack 中第一次出现的位置。大小写敏感。

如果成功,则返回位置,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数:

haystack:在该字符串中进行查找。

needle:如果 needle 不是一个字符串,那么它将被转换为整型并被视为字符的顺序值。

offset:如果提供了此参数,搜索会从字符串该字符数的起始位置开始统计。和 strrpos()、 strripos()不一样,这个偏移量不能是负数。

$mystring = 'helloworld';

$findme   = 'l';
$pos = strpos($mystring, $findme); //$pos值为2 $findme = 'L';
$pos = strpos($mystring, $findme); //$pos值为false $findme = 'q';
$pos = strpos($mystring, $findme); //$pos值为false

stripos

语法:

mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )

查找 needle 在 haystack 中第一次出现的位置。大小写不敏感。

如果成功,则返回位置,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数:

haystack:在该字符串中查找。

needle:注意 needle 可以是一个单字符或者多字符的字符串。如果 needle 不是一个字符串,那么它将被转换为整型并被视为字符顺序值。

offset:可选的 offset 参数允许你指定从 haystack 中的哪个字符开始查找。返回的位置数字值仍然相对于haystack 的起始位置。

$mystring = 'helloworld';

$findme   = 'l';
$pos = stripos($mystring, $findme); //$pos值为2 $findme = 'L';
$pos = stripos($mystring, $findme); //$pos值为2 $findme = 'q';
$pos = stripos($mystring, $findme); //$pos值为false

*******************************************************************************************************************

strrpos() 函数

语法 
mixed strrpos ( string $haystack , string $needle [, int $offset = 0 ] )

查找 needle 在 haystack 中最后一次出现的位置。大小写敏感。

如果成功,则返回位置,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数

haystack:在此字符串中进行查找。

needle:注意 needle 可以是一个单字符或者多字符的字符串。

offset:或许会查找字符串中任意长度的子字符串。负数值将导致查找在字符串结尾处开始的计数位置处结束。

$mystring = 'helloworld';

$findme   = 'l';
$pos = strrpos($mystring, $findme); //$pos值为8 $findme = 'L';
$pos = strrpos($mystring, $findme); //$pos值为false $findme = 'q';
$pos = strrpos($mystring, $findme); //$pos值为false

strripos() 函数

语法
mixed strripos ( string $haystack , string $needle [, int $offset = 0 ] )

查找 needle 字符串在 haystack 中最后一次出现的位置。大小写不敏感。

如果成功,则返回位置,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数

haystack:在此字符串中进行查找。

needle:注意 needle 可以是一个单字符或者多字符的字符串。

offset:参数 offset 可以被指定来查找字符串中任意长度的子字符串。负数偏移量将使得查找从字符串的起始位置开始,到 offset 位置为止。

$mystring = 'helloworld';

$findme   = 'l';
$pos = strripos($mystring, $findme); //$pos值为8 $findme = 'L';
$pos = strripos($mystring, $findme); //$pos值为8 $findme = 'q';
$pos = strripos($mystring, $findme); //$pos值为false

*******************************************************************************************************************

strstr () 函数(strchr)

语法
string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )

返回 needle 在 haystack 中第一次出现的位置开始到结尾的字符串。大小写敏感。
如果成功,则返回字符串,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数

haystack:输入字符串。

needle:如果 needle 不是一个字符串,那么它将被转化为整型并且作为字符的序号来使用。

before_needle:若为 TRUE,strstr() 将返回 needle 在 haystack 中的位置之前的部分。

$mystring = 'helloworld';

$findme   = 'l';
$pos = strstr($mystring, $findme); //$pos值为lloworld $findme = 'L';
$pos = strstr($mystring, $findme); //$pos值为false $findme = 'q';
$pos = strstr($mystring, $findme); //$pos值为false

stristr () 函数

语法
string stristr ( string $haystack , mixed $needle [, bool $before_needle = false ] )

返回 needle 在 haystack 中最后一次出现的位置到结尾的字符串。大小写不敏感。
如果成功,则返回字符串,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数

haystack:在该字符串中查找。

needle:如果 needle 不是一个字符串,那么它将被转换为整型并被视为字符顺序值。

before_needle:若为 TRUEstrstr() 将返回 needle 在 haystack 中的位置之前的部分(不包括 needle)。

$mystring = 'helloworld';

$findme   = 'l';
$pos = stristr($mystring, $findme); //$pos值为lloworld $findme = 'L';
$pos = stristr($mystring, $findme); //$pos值为lloworld $findme = 'q';
$pos = stristr($mystring, $findme); //$pos值为false

*******************************************************************************************************************

strrchr() 函数

语法
string strrchr ( string $haystack , mixed $needle )

返回 haystack 字符串中的一部分,这部分以 needle 的最后出现位置开始,直到 haystack 末尾。
如果成功,则返回字符串,否则返回 false。

正则:/ /i ,有i,表示不区分大小写,同样,这里类似:没有i表示区分大小写,有i表示不区分大小写

参数

haystack:在此字符串中进行查找。

needle:注意 needle 可以是一个单字符或者多字符的字符串。

offset:参数 offset 可以被指定来查找字符串中任意长度的子字符串。负数偏移量将使得查找从字符串的起始位置开始,到 offset 位置为止。

$mystring = 'helloworld';

$findme   = 'l';
$pos = strrchr($mystring, $findme); //$pos值为ld $findme = 'L';
$pos = strstr($mystring, $findme); //$pos值为false $findme = 'q';
$pos = strstr($mystring, $findme); //$pos值为false

strrichr()函数 -- 没有

********************************************************************************************************************

最新文章

  1. SharePoint2016母版页的直接依赖项的数目限制超过10的限制解决方案Direct Dependencies Limit with Master page User Controls
  2. JS 获取客户端操作系统
  3. 关于Linux:chmod和chown知识
  4. [windows操作系统]windows管理
  5. [Everyday Mathematics]20150227
  6. 自己开发开源jquery插件--给jquery.treeview加上checkbox
  7. ASP.NET MVC 自定义错误页面心得
  8. cocos2d-x3.0 解释具体的新的物理引擎setCategoryBitmask()、setContactTestBitmask()、setCollisionBitmask()
  9. Webpack执行命令参数详解
  10. Python004-数据处理示例:以某个数据(字段)为基准从数据中获取不同的字段行数
  11. c# 参数名ascii码从小到大排序(字典序)拼接
  12. orcad 自带常用原理图库解析
  13. 导出CSV乱码
  14. 5个强大的Java分布式缓存框架
  15. spring boot打jar包(maven对jar和lib分离)
  16. VC++6.0调试:Watch窗口的使用
  17. 如何给Windows Server 2012 R2 添加“磁盘清理”选项
  18. Seleniumz中 dr.quit()和dr.close()的区别
  19. OGNL概述
  20. VS2017更新后 在WIN7上找不到 stdio.h等的问题

热门文章

  1. nested exception is java.lang.IllegalStateException: Cannot forward after response has been committed
  2. java面试题(开发框架)
  3. e.keycode详解
  4. MySQL数据库字符集由utf8修改为utf8mb4一例
  5. unity, switch platform
  6. getconf命令【一天一个命令】
  7. C++ 基类指针和子类指针相互赋值
  8. makefile之wildcard函数
  9. php的ord函数——解决中文字符截断问题
  10. zookeeper是如何选取主leader的?