PHP str_split() is an inbuilt function that splits a string into an array. The str_split() function converts PHP string to array. The function splits the given string into smaller strings of the length specified by a user and stores them in the array and returns an array.

PHP str_split Function

The syntax of the str_split() method is following.

str_split(string, length)

The string parameter is required, and it specifies the string to split.

The length parameter is optional, and it specifies the length of each array element. Default is 1.

See the following code example.

<?php
print_r(str_split("Millie Bobby Brown", 6));

See the output.

#php #php str_split

PHP str_split() Function Example | str_split() Function Tutorial
1.35 GEEK