首页  >  文章  >  后端开发  >  如何避免这段字符串,为数组赋值

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

WBOY
WBOY原创
2016-06-13 10:35:16809浏览

如何处理这段字符串,为数组赋值
如何处理这段字符串:
"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