PHP str_split Function

What is str_split Function?

Explanation

In PHP, this function is used to convert a string to an array.

Syntax:


str_split(string,length)

In the above syntax "string" specified is converted to an array, "length" specifies the length of each element.

Example :


<?php
print_r(str_split("Halloween"));
?>
Result :

Array
(
[0] => H
[1] => a
[2] => l
[3] => l
[4] => o
[5] => w
[6] => e
[7] => e
[8] => n
)

In the above example "Halloween" is split into a array of individual string.

PHP Topics


Ask Questions

Ask Question