Home > Article > Backend Development > How to use the explode() function to split a string into an array in PHP
The function of the explode() function: Use one string to split another string and break it into an array. This article will introduce to you how to use the explode() function in PHP to split a string into an array. Friends who need it can refer to the function of the
explode() function: use one string to split another string and break it up. is an array.
For example:
String
$pizza = "第1 第2 第3 第4 第5 第6";
After splitting according to spaces: $pieces = explode(" " , $pizza);
$pieces is the divided array, let’s print it out and see
"; } piece1 piece2 piece3 piece4 piece5 piece6
Example 2: According to Comma separated
"; }
Output result:
The sun is very bright today
We didn’t go out. We had a great time eating in the cafeteria at noon!
PHP uses preg_split and explode to implement splitting textarea to store content
php explodeFunction introduction and detailed explanation of usage
2017php explodeSummary of function definition and usage
The above is the detailed content of How to use the explode() function to split a string into an array in PHP. For more information, please follow other related articles on the PHP Chinese website!