Php chunk split
From w3cyberlearnings
Contents |
PHP function chunk_split
This function splits a string into parts.
Syntax chunk_split
- string: string to be split
- length (optional): length to be split
- end (optional): define what to place at the end of each chunk.
chunk_split(string,length,end)
Example 1
<?php $myList ='Lovely day, and we go to the beach'; $my_chunt_split = chunk_split($myList,3); echo $my_chunt_split; ?>
Output
- Split string into three characters length
Lov ely da y, and we go to th e b eac h
Example 2
- split into three characters length and end with '&'.
<?php $myList ='Lovely day, and we go to the beach'; $my_chunt_split = chunk_split($myList,3,'&'); echo $my_chunt_split; ?>
Output
Lov&ely& da&y, &and& we& go& to& th&e b&eac&h&