PHP chunk_split() Function

PHP chunk_split() function is used to split a string into smaller chunks.


string chunk_split(str,length,end);

chunk_split() Function Parameter

str :Required parameter. The string to be chunked.
length :Required parameter. The chunk length.
end :Required parameter. The line ending sequence.

chunk_split() Function Return Value

Return Value :Returns the chunked string.

chunk_split() Function Example

// split string after each second character and add a "|" after each split
echo chunk_split("The string to be chunked!",2,"|");