PHP字符串函数

https://www.cnblogs.com/xu1115/p/10916423.html(简要说明函数作用,主要有很多未曾见过或使用过的神奇函数)

https://blog.csdn.net/qq_35458793/article/details/80651773 (简要说明函数用法与返回数值)

以上两个博客是别人整理好的,更全的函数介绍可以直接进去参考。

substr()  返回字符串 string 由 start 和 length 参数指定的子字符串。截取字符串

  substr ( string $string , int $start [, int $length ] ) : string

strpos()  查找字符串首次出现的位置, 如果没找到 needle,将返回 FALSE

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

  如果提供了offset 参数,搜索会从字符串该字符数的起始位置开始统计。 如果是负数(php7.1),搜索会从字符串结尾指定字符数开始。

strstr() 返回 haystack 字符串从 needle 第一次出现的位置开始到 haystack 结尾的字符串。

  strstr ( string $haystack , mixed $needle [, bool $before_needle = FALSE ] ) : string

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

str_split() 将字符串转为数组

  str_split ( string $string [, int $split_length = 1 ] ) : array

count_chars () 统计 string 中每个字节值(0..255)出现的次数,使用多种模式返回结果。

  count_chars ( string $string [, int $mode = 0 ] ) : mixed 

  根据不同的 modecount_chars() 返回下列不同的结果:

  • 0 - 以所有的每个字节值作为键名,出现次数作为值的数组。
  • 1 - 与 0 相同,但只列出出现次数大于零的字节值。
  • 2 - 与 0 相同,但只列出出现次数等于零的字节值。
  • 3 - 返回由所有使用了的字节值组成的字符串。
  • 4 - 返回由所有未使用的字节值组成的字符串。

substr_count() 返回子字符串 needle 在字符串 haystack 中出现的次数。注意 needle 区分大小写。

  substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] ) : int

  该函数不会计算重叠字符串!

  7.1.0 开始支持负数的 offset 和 length

原文地址:https://www.cnblogs.com/lz0925/p/13903468.html