This time I will bring you StringSplit into array, what are the precautions for splitting a string into an array, the following is a practical case, one Get up and take a look.
The example is as follows:
<?php $str="1|2|3|4|5|"; $var=explode("|",$str); print_r($var); ?> $var=explode("|",$str);
Split $str by |
php and other ways to specify strings Characters are split into arrays
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.
json_decode() This function can also split the string into an array (the second parameter is true)
I believe you have mastered the method after reading the case in this article, please come for more exciting information Pay attention to other related articles on php Chinese website!
Recommended reading:
php retains key value + detailed explanation of merging arrays
How to reset the array to a numeric index
The above is the detailed content of Split string into array. For more information, please follow other related articles on the PHP Chinese website!