Home >>PHP String Functions >PHP str_split() Function
PHP str_split() function is used to convert a given input string into an array. It splits the given input string into smaller strings of specified length and stores them into an array and returns that array.
Syntax:
str_split($string, $length);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter contains the given string to split. |
length | This is an optional parameter. This parameter defines the length of each array element. By default it’s value is 1. |
Here is an example of str_split() function in PHP:
<html> <body> <pre> <?php $str = "PHPTPOINT"; print_r(str_split($str)); ?> </pre> </body> </html>
Here is an example of str_split() function in PHP:
<html> <body> <pre> <?php $str= "Hello Everyone!! I'm Jerry..."; print_r(str_split($str,3)); ?> </pre> </body> </html>