Home  >  Article  >  Backend Development  >  如何避免这段字符串,为数组赋值

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

WBOY
WBOYOriginal
2016-06-13 10:35:16812browse

如何处理这段字符串,为数组赋值
如何处理这段字符串:
"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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP 处置多重数组Next article:PHP生成XML如何换行