Today, I saw a post in the php forum asking my friend how to convert a string into an array. As a new php programmer, the first response is to think of explode (), implode () these two functions. The new one is also converted to an array using the functions in it. Con [1] 28 selt [1] 1con [2] 29 selt [2] 4con [3] 26 selt [3] 4con [4] 30 s
Today, I saw a post in the php forum asking my friend how to convert a string into an array. As a new php programmer, the first response is to think of explode (), implode () these two functions. The new one is also converted to an array using the functions in it. Con [1] = 28 selt [1] = 1con [2] = 29 selt [2] = 4con [3] = 26 selt [3] = 4 con [4] = 30 s
Today, I saw a post in the php forum asking my friend how to convert a string into an array. As a new php programmer, the first response is to think of explode (), implode () these two functions. The new one is also converted to an array using the functions in it.
Con [1] = 28 & selt [1] = 1 & con [2] = 29 & selt [2] = 4 & con [3] = 26 & selt [3] = 4
& Con [4] = 30 & selt [4] = 2 & con [5] = 4 & selt [5] = 1 & con [6] = 11 & con [7] = 12
The above is the string that netizens need to convert to the PHP array; below is the new PHP conversion code
$ V) {$ arr = explode ('=', $ v); $ arr2 [$ k] = $ arr [1];} print_r ($ arr2);?> // Output Array ([0] => 28 [1] => 1 [2] => 29 [3] => 4 [4] => 26 [5] => 4 [6] => 30 [7] => 2 [8] => 4 [9] => 1 [10] => 11 [11] => 12) // second
$ V) {$ arr = explode ('=', $ v); $ arr2 [$ arr [0] = $ arr [1];} print_r ($ arr2);?> // Output Array ([con [1] => 28 [selt [1] => 1 [con [2] => 29 [selt [2] => 4 [con [3] => 26 [selt [3] => 4 [con [4] => 30 [selt [4] => 2 [con [5] => 4 [selt [5] => 1 [con [6] => 11 [con [7] => 12)
The new PHP code can also solve the problem of converting strings into arrays. Finally, phper users should find the parse_str () function in the manual to convert the string into a PHP array. The following describes the description of the parse_str () function to impress themselves.
The parse_str () function parses the query string to a variable.
Parse_str (string, array) string: string to be converted; array: returned to an array; If array is not set, the variable with the same name is overwritten.
Original article address: Convert the php operation string to an array. Thank you for sharing it.