Maison >développement back-end >tutoriel php > php 字符串操作,该怎么解决
php 字符串操作
$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";
$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";<br /> <br /> foreach(explode("\r\n", $getstr) as $row) {<br /> if($row) {<br /> parse_str(strtr($row, ',', '&'), $t);<br /> $res[] = $t;<br /> }<br /> }<br /> <br /> echo $res[0]['id'];