Latest web development tutorials

PHP chunk_split () function

PHP String Reference PHP String Reference

Examples

Split a string after each character, and add after each division. "":

<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>

Running instance »

Definition and Usage

chunk_split () function of the string is divided into a series of smaller parts.

Note: This function does not change the original string.


grammar

chunk_split( string,length,end )

参数 描述
string 必需。规定要分割的字符串。
length 可选。一个数字,定义字符串块的长度。默认为 76。
end 可选。一个字符串,定义在每个字符串块之后放置的内容。默认为 \r\n。

technical details

return value: Returns the string to split.
PHP version: 4+


More examples

Example 1

Split a string after each six characters, and add after each split "...":

<?php
$str = "Hello world!";
echo chunk_split($str,6,"...");
?>

Running instance »


PHP String Reference PHP String Reference