PHP chunk_split() Function

Last Updated:

PHP chunk_split()

The chunk_split() function splits a string into smaller chunks.

Note: This function does not alter the original string.

Example

PHP Compiler
<?php $str = "PHP World"; echo chunk_split($str, 1, "."); ?>

Syntax

chunk_split(str, chunklen, end)

Parameter Values

ValueTypeExplanation
str Required Specifies the string to split.
chunklen Optional Specifies the chunk length.
end Optional Specifies the end of each chunk.
Default value is \r\n.

Return Value

ValueExplanation
Number Returns the chunked string.

More Examples

Example

PHP Compiler
<?php $str = "PHP World"; echo chunk_split($str, 2, ".."); ?>

Share this Page

Meet the Author