Home > Article > Backend Development > What does strsplt mean in php?
In PHP, strsplt refers to the str_split() function, which means splitting a string. This function can split a string, split the string into substrings of a specified length, and add the substrings one by one. Pass in the array as the array element; syntax "str_split (string, length value)", the second parameter of the function can be omitted.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, strsplt refers to str_split( ) function, which means splitting a string.
The str_split() function can split a string, split the string into substrings of a specified length, and pass the substrings into the array one by one as array elements.
Syntax:
str_split($string,$length)
Parameter description:
$string: required parameter. Specifies the string to be split.
#$length: can be omitted. Specifies the length of each array element. The default is 1, so the string will be split into characters and the string will be converted into a character array.
If $length is omitted or 1, return the character array
<?php header("Content-type:text/html;charset=utf-8"); $str= "Hello"; $arr=str_split($str); var_dump($arr); $arr=str_split($str,1); var_dump($arr); ?>
If $length is greater than or equal to the length of the string, the entire The string will be returned as the only element of the array.
<?php header("Content-type:text/html;charset=utf-8"); $str= "Hello"; $arr=str_split($str,5); var_dump($arr); $arr=str_split($str,6); var_dump($arr); ?>
If $length is less than 1, the str_split() function will return FALSE.
<?php header("Content-type:text/html;charset=utf-8"); $str= "Hello"; $arr=str_split($str,0); var_dump($arr); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does strsplt mean in php?. For more information, please follow other related articles on the PHP Chinese website!