ITPub博客

首页 > IT职业 > IT图书 > php中的chunk_split()和str_split()字符串函数

php中的chunk_split()和str_split()字符串函数

IT图书 作者:nt1979 时间:2021-09-09 09:20:09 0 删除 编辑

chunk_split(string $string,[,int $length[,string $end="rn"]]),将字符串按一定长度分割,结果返回分割后的字符串。str_split(string $string[,int $length=1])将字符串按一定长度进行分割,结果返回一个数组,分割后的每个串就是数组的单元。

$str="hello world";

echo chunk_split($str,3,"end");//结果返回helendlo endworendldend

print_r str_split($str,3);//结果返回Array([0]=>hel [1]=>lo  [2]=>wor [3]=>ld)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4822/viewspace-2802347/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-05

  • 博文量
    318
  • 访问量
    17303