Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP str_split() Function

PHP str_split() Function

PHP String Reference Manual PHP String Reference Manual

Example

Split the string "Hello" into an array:

Run Example »


Definition and Usage

The str_split() function splits a string into an array.


Syntax

str_split(

string,length

)

Parameters Description
string Required. Specifies the string to split.
length Optional. Specifies the length of each array element. Default is 1.

Technical Details

Return Value: If length is less than 1, the str_split() function returns FALSE. If length is greater than the length of the string, the entire string is returned as the only element of the array.
PHP Version: 5+

More examples

Example 1

Use the length parameter:

Run Example »


PHP String Reference Manual PHP String Reference Manual