PHP's chunk_split() function

不言
Release: 2023-03-23 16:42:02
Original
2070 people have browsed it

This article introduces to you the chunk_split() function of PHP. Now I share it with you. Friends in need can refer to it


Definition and usage


#The chunk_split() function splits a string into a series of smaller parts.

Note: This function does not change the original string.



## Grammar

chunk_split(string,length,end)
Copy after login



##Parametersstringlengthend

Technical details

Description
Required. Specifies the string to be split.
Optional. A number defining the length of the string block. Default is 76.
Optional. A string defining what is placed after each string block. Default is \r\n.
Return value: Returns the split string.
PHP version: 4





实例 1


在每个字符后分割一次字符串,并在每个分割后添加 ".":

源代码:

<!DOCTYPE html>
<html>
<body>
Copy after login
<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>
  
  
</body>
</html>
Copy after login


运行结果:

H.e.l.l.o. .w.o.r.l.d.!.

实例 2


在每六个字符后分割一次字符串,并在每个分割后添加 "...":

源代码:

<!DOCTYPE html>
<html>
<body>

  

Copy after login



运行结果:

Hello ...world!...

Related recommendations:

php splits a string into a series of smaller parts function chunk_split()

10 recommended articles about the string function chunk_split()

chunk_split( in php ) function usage introduction

The above is the detailed content of PHP's chunk_split() function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!