首頁  >  文章  >  後端開發  >  如何避免这段字符串,为数组赋值

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

WBOY
WBOY原創
2016-06-13 13:21:04970瀏覽

如何处理这段字符串,为数组赋值
如何处理这段字符串:
"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)); <div class="clear">
                 
              
              
        
            </div>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn