Latest web development tutorials

PHP str_split () function

PHP String Reference PHP String Reference

Examples

The string "Hello" into array:

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

Running instance »

Definition and Usage

str_split () function to split a string into an array.


grammar

str_split( string,length )

参数 描述
string 必需。规定要分割的字符串。
length 可选。规定每个数组元素的长度。默认是 1。

technical details

return value: If the length is less than 1, str_split () function returns FALSE. If the 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 length parameters:

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

Running instance »


PHP String Reference PHP String Reference