Split the string once after each character and add "." after each split:
<?php$str = "Hello world!";echo chunk_split($str,1,".");?>The chunk_split() function splits a string into a series of smaller parts.
Note: This function does not change the original string.
chunk_split( string,length,end )
parameter | describe |
---|---|
string | Required. Specifies the string to be split. |
length | Optional. A number defining the length of the string block. The default is 76. |
end | Optional. A string defining what is placed after each string block. The default is rn. |
Return value: | Returns the split string. |
---|---|
PHP version: | 4+ |
Split the string after every six characters and add "..." after each split:
<?php$str = "Hello world!";echo chunk_split($str,6,"...");?>