WHAT IS THE SYNTAX OF THE STR_SPLIT()FUNCTION IN PHP?
str_split(string,length)
Parameter | Description |
---|---|
string | Required. Specifies the string to split |
length | Optional. Specifies the length of each array element. Default is 1 |
EXAMPLES OF THE STR_SPLIT() FUNCTION
Example 1. In this example, we split the string “Hello” into an array.
<?php
print_r(str_split("Hello"));
?>
Example 2. In this example, we use the length parameter.
<?php
print_r(str_split("Hello",3));
?>