There are many ways to convert strings into arrays in PHP. If we have regularity, we can directly use the explode() function to cut the string into an array.
Definition and usage
The explode() function splits a string into an array.
Grammar
explode(separator,string,limit)
Example
In this example, we will split the string into an array:
The code is as follows | Copy code | ||||
print_r (explode(" ",$str)); ?>
|
代码如下 | 复制代码 |
Array |
The code is as follows | Copy code |
Array |
There are many ways to convert strings into arrays in php. If we have regularity, we can use it directly. explode() function to cut the string into an array. Definition and usage explode() function puts...