Home > Article > Backend Development > Can php split two characters?
php can split characters. The method is: 1. Split one string into another string through the explode function; 2. Split the string into an array through the str_split function.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Can php split two characters?
php can split characters:
explode()
: Use one string to split another string;
str_split()
: Split the string into an array;
explode() The function uses one string to split another string and returns the characters Array of strings.
Note: The "separator" parameter cannot be an empty string.
Note: This function is binary safe.
Syntax
explode(separator,string,limit)
separator Required. Specifies where to split the string.
string Required. The string to split.
limit Optional. Specifies the number of array elements to be returned.
Possible values:
Greater than 0 - returns an array containing at most limit elements Less than 0 - returns an array containing all but the last -limit elements 0 - will be treated as 1. Return an array containing one element
str_split() The function splits the string into an array.
Syntax
str_split(string,length)
string Required. Specifies the string to be split.
length Optional. Specifies the length of each array element. The default is 1.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Can php split two characters?. For more information, please follow other related articles on the PHP Chinese website!