-4

I tried to parse a JSON file using PHP. But i'am stuck now.

This is my JSON file

{
  "status": "200",
  "port": "7777",
  "maxplayers": 10,
  "playercount": "2",
  "players": "citron6946, Galios, Example"
  "uptime": "4.06:17:21",
} 

And my PHP so far ... I need only simple text display where you adjust the font

Status: online
Uptimne: 4d 6h 17m 21s
Port: 7777
Maxplayers: 10
Players: citron6946, Galios, Example

Can you help me ?

1 Answers1

0

You can now print it.

<?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);

output:

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

EDIT

Replace

echo var_dump($out):

to

foreach($out as $key=> $value) echo $key.":".$value."<br>";

output:

status:200
port:7777
maxplayers:10
playercount:2
players:citron6946, Galios, Example
uptime:4.06:17:21
ajtamwojtek
  • 763
  • 6
  • 19
  • It doesn't depend on json. You should use Ajax to make this script automated. Do you download json from other site or what? – ajtamwojtek Apr 26 '14 at 21:00