Current Location: Home> Function Categories> str_split

str_split

Convert strings to arrays
Name:str_split
Category:String
Programming Language:php
One-line Description:Split the string into an array.

Definition and usage

str_split() function splits the string into an array.

Example

Example 2

Split the string "Shanghai" into an array:

 <?php
print_r ( str_split ( "Shanghai" ) ) ;
?>

Try it yourself

Example 2

Use length parameter:

 <?php
print_r ( str_split ( "Shanghai" , 3 ) ) ;
?>

Try it yourself

grammar

 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.