263
PHP string str_split() Function
The str_split() is predefined function of PHP. It is used to convert a string to an array. If the split length is specified, then array will be broken down into chunks with length.
It will return FALSE if the split length is less than 1.
Syntax:
Parameter | Description | Required/Optional |
---|---|---|
String | Specify the string to split. | Required |
Length | Specify the length of each array element. Default is :1 | Optional |
Example 1
Output:
Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => P [7] => H [8] => P )
Example 2
Output:
Array ( [0] => Hel [1] => lo [2] => PHP )
Reference:
http://php.net/manual/en/function.str-split.php
Next TopicPHP String