简体   繁体   中英

Convert a string into multiple variables and values

I would like to convert the string:

{ "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 }

Into something like :

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

Just decode the JSON in your string, and then extract it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM