This article introduces the usage of the chunk_split() function in PHP. Friends in need can refer to it.
Definition and usage chunk_split function splits a string into a series of smaller parts. Grammar chunk_split(string,length,end) Parameter Description string required. Specifies the string to be split. length is optional. A number defining the length of the string block. end is optional. A string value that defines what is placed after each string block. Tips and Notes Note: This function does not change the original string. Example 1, separate each character and add ".": <?php $str = "Hello world!"; echo chunk_split($str,1,"."); //by bbs.it-home.org ?> Copy after login Output: H.e.l.l.o. .w.o.r.l.d.!. Example 2, split the string once after six characters and add "...": <?php $str = "Hello world!"; echo chunk_split($str,6,"..."); //by bbs.it-home.org ?> Copy after login Output: Hello...world!... |