In PHP, the explode () function is used to cut the string into an array. The explode Array
The function of explode () is used to split another string into arrays.
For example:
String
$ Pizza = "1st 2nd 3rd 4th 5th 6th ";
After separation by space:$ Pieces = explode (", $ pizza );
$ Pieces is the split array. Let's print it and see it.
<? Php $ pizza = "1st 2nd 3rd 4th 5th"; $ pieces = explode ("", $ pizza); foreach ($ pieces as $ val) {echo $ val. "<br>";} piece1piece2piece3piece4piece5piece6
Example 2: Separate data by commas
<? Php $ string = 'Today the sun is very big, and we have not gone out. At noon, we had a good time dining room! '; $ String_arr = explode (",", $ string); foreach ($ string_arr as $ val) {echo $ val. "<br> ";}
Output result:
Today, the sun is very large.
We did not go out. We will have dinner in the dining room at noon.
Happy!
The above is an example of using the explode () function to cut strings into arrays in PHP. I hope to help you. If you have any questions, please leave a message, the editor will reply to you in time!