将字符串转换为多个变量和值

时间:2014-02-12 00:52:39

标签: php string variables

我想转换字符串:

{ "summonerLevel": 6, "name": "Nautilus", "dataVersion": 0, "internalName": "nautilus", "profileIconId": 4, "summonerId": 37399097, "acctId": 200656209, "revisionDate": "Sep 4, 2013 12:43:34 p.m.", "revisionId": 0 }

类似于:

$summonerLevel=6;
$name="Nautilus";
$dataVersion=0;

1 个答案:

答案 0 :(得分:2)

只需解码字符串中的JSON,然后将其解压缩:

$vars = json_decode('{ ... }');
extract($vars);