PHP chunk_split() function is used to split a string into smaller chunks.
Syntax
string chunk_split(str,length,end);
Parameter | Description |
---|---|
str : | Required parameter. The string to be chunked. |
length : | Required parameter. The chunk length. |
end : | Required parameter. The line ending sequence. |
Return Value : | Returns the chunked string. |
<?php // split string after each second character and add a "|" after each split echo chunk_split("The string to be chunked!",2,"|"); ?>