我尝试使用PHP解析JSON文件。但我现在卡住了。
这是我的JSON文件
{
"status": "200",
"port": "7777",
"maxplayers": 10,
"playercount": "2",
"players": "citron6946, Galios, Example"
"uptime": "4.06:17:21",
}
到目前为止我的PHP ... 我只需要简单的文本显示来调整字体
Status: online
Uptimne: 4d 6h 17m 21s
Port: 7777
Maxplayers: 10
Players: citron6946, Galios, Example
你能帮助我吗?
答案 0 :(得分:0)
您现在可以打印它了。
<?php
$json = '{"status": "200","port": "7777","maxplayers": 10,"playercount": "2","players": "citron6946, Galios, Example","uptime": "4.06:17:21"}';
$out = json_decode($json, true);
echo var_dump($out);
输出:
array(6) {
["status"]=>
string(3) "200"
["port"]=>
string(4) "7777"
["maxplayers"]=>
int(10)
["playercount"]=>
string(1) "2"
["players"]=>
string(27) "citron6946, Galios, Example"
["uptime"]=>
string(10) "4.06:17:21"
}
修改强>
替换
echo var_dump($out):
到
foreach($out as $key=> $value) echo $key.":".$value."<br>";
输出:
status:200
port:7777
maxplayers:10
playercount:2
players:citron6946, Galios, Example
uptime:4.06:17:21