chunk_split
Split the string into smaller chunks
The chunk_split()
function divides the string into a series of smaller parts.
Note: This function does not change the original string.
Split the string once after each character and add "." after each segment:
<?php $str = "Shanghai" ; echo chunk_split ( $str , 1 , "." ) ; ?>
Try it yourself
Split the string once after every six characters and add "..." after each segment:
<?php $str = "Hello world!" ; echo chunk_split ( $str , 6 , "..." ) ; ?>
Try it yourself
chunk_split ( string , length , end )
parameter | describe |
---|---|
string | Required. Specifies the string to be divided. |
length | Optional. numeric value, defining the length of the string block. The default is 76. |
end | Optional. String value, which defines what is placed at the end of each string block. The default is \r\n. |