php String to array method: First create a PHP sample file; then use the explode function to split a string and return an array, or use the "str_split" function to convert the string into an array.
Recommended: "PHP Video Tutorial"
php string to array method:
explode — Use one string to split another string and return an array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Here if the string If there is no symbol to split, you need to consider other methods
str_split - Convert the string to an array
1 2 3 4 5 6 7 8 9 10 11 |
|
Output result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
If it is incompatible, The only other way to consider is to break the string bit by bit.
Here is a manual method to break the string, which is a method originally used to verify Japanese half-width kana.
Here is an enumeration of half-width pseudonyms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
This is a matching rule. Note that i = 2 here, because one text occupies 2 bits
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The above is the detailed content of How to convert php string to array. For more information, please follow other related articles on the PHP Chinese website!