Php string operations
$ Getstr = "id = 189, pc = 0, pt = 0, valide = 1 \ r \ nid = 176, pc = 0, pt = 0, valide = 1 \ r \ nid = 177, pc = 0, pt = 0, valide = 1 \ r \ n ";
I want to divide the string in the form of \ r \ n, get an array, and then take the value in the form of a key-value pair,
Take the value of the first id as an example.
$ Getid = $ arr ["id"]
Please advise me
Reply to discussion (solution)
Replace \ r \ n with 2 points, and then restore it to an array... other...
Replace \ r \ n with 2 points, and then restore it to an array... other...
Can I post code. Daniel ..
Explode ("\ r \ n ",)
Explode (",",)
$ Getstr = "id = 189, pc = 0, pt = 0, valide = 1 \ r \ nid = 176, pc = 0, pt = 0, valide = 1 \ r \ nid = 177, pc = 0, pt = 0, valide = 1 \ r \ n "; foreach (explode (" \ r \ n ", $ getstr) as $ row) {if ($ row) {parse_str (strtr ($ row, '&'), $ t ); $ res [] = $ t;} echo $ res [0] ['id'];