Home >Backend Development >PHP Tutorial >PHP operates string split into array
This time I will bring you php operationStringsplit intoarray, what are the precautions for php operation string split into array, the following are Let’s take a look at practical cases.
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:
Summary of methods to prevent SQL injection in PHP
What are the methods for generating complex verification codes in PHP
The above is the detailed content of PHP operates string split into array. For more information, please follow other related articles on the PHP Chinese website!