In PHP, split is often used in the "str_split" function, which can split a string into an array. The usage is "str_split(string,length)"; when length is less than 1, this function will return false , when length is greater than the length of the string, the entire string is returned.
The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer
str_split() function splits a string into an array.
Syntax
str_split(string,length)
Parameter Description
string Required. Specifies the string to be split.
length Optional. Specifies the length of each array element. The default is 1.
Return value: If length is less than 1, the str_split() function will return FALSE. If length is greater than the length of the string, the entire string is returned as the only element of the array.
The example is as follows:
<?php print_r(str_split("Hello")); ?>
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What is the usage of str_split in php. For more information, please follow other related articles on the PHP Chinese website!