当前位置:Gxlcms > PHP教程 > 如何避免这段字符串,为数组赋值

如何避免这段字符串,为数组赋值

时间:2021-07-01 10:21:17 帮助过:15人阅读

如何处理这段字符串,为数组赋值
如何处理这段字符串:
"BronzeList":[],"GoldList":["ATM054000"],"SilverList":["ATW099000"],"nation":"GER","nationName":"德国","rank":1,"rankTotal":1,"sortRank":1,"sortRankTotal":1,"totalBronze":8,"totalGold":8,"totalMedal":22,"totalSilver":6
来为数组赋值$array($key=>$value),使用逗号分割字符串,每项使冒号前面的内容为数组的$key,冒号后面的内容为数组的$value。
赋值的数组结果例如:$array = ("BronzeList"=>null,"GoldList"=>"ATM054000","SilverList"=>"ATW099000","nation"=>"GER",,,,)

求大侠帮忙。

------解决方案--------------------
他不是 json 吗?
------解决方案--------------------
PHP code
$json='{"BronzeList":[],"GoldList":["ATM054000"],"SilverList":["ATW099000"],"nation":"GER","nationName":"德国","rank":1,"rankTotal":1,"sortRank":1,"sortRankTotal":1,"totalBronze":8,"totalGold":8,"totalMedal":22}';
print_r(json_decode($json,true));                     

人气教程排行