Use the explode () function in PHP to cut strings into arrays and explode arrays.
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> ";}
Piece1
Piece2
Piece3
Piece4
Piece5
Piece6
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!
My blog: using the explode () function in PHP to cut strings into Arrays