PHP chunk_split() Function
Example
Split the string every character and add "." after each split:
<?php $str = "Shanghai"; echo chunk_split($str,1,"."); ?>
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.
Syntax
chunk_split(string,length,end)
Parameter | Description |
---|---|
string | Required. Specifies the string to be split. |
length | Optional. Numeric value, defines the length of the string block. The default is 76. |
end | Optional. String value, defines the content placed at the end of each string block. The default is \r\n. |
Technical Details
Return Value: | Return the split string. |
PHP Version: | 4+ |
More Examples
Example 1
Split the string every six characters and add "..." after each split:
<?php $str = "Hello world!"; echo chunk_split($str,6,"..."); ?>