str_split
Convert strings to arrays
str_split()
function splits the string into an array.
Split the string "Shanghai" into an array:
<?php print_r ( str_split ( "Shanghai" ) ) ; ?>
Try it yourself
Use length parameter:
<?php print_r ( str_split ( "Shanghai" , 3 ) ) ; ?>
Try it yourself
str_split ( string , length )
parameter | describe |
---|---|
string | Required. Specifies the string to be divided. |
length | Optional. Specifies the length of each array element. The default is 1. |