How to Display Various Values of a JSON in PHP

Asked

Viewed 380 times

4

How can I display all the values of a JSON in PHP ??

Let me give you an example, I use the Code below to request JSON

    $json_file = file_get_contents("http://backpack.tf/api/IGetUsers/v3/?steamids=76561198012598620");
$json_str = json_decode($json_file, true);
The information contained in JSON is this:
{
    "response": {
        "success": 1,
        "current_time": 1400075229,
        "players": {
            "76561198012598620": {
                "steamid": "76561198012598620",
                "success": 1,
                "backpack_value": {
                    "570": 5,
                    "440": 126.9475
                },
                "backpack_update": {
                    "570": 1399815523,
                    "440": 1400024876
                },
                "name": "Fiskie",
                "backpack_tf_reputation": 2,
                "notifications": 0
            }
        }
    }
}
But if I use
$nome = $json_str["name"];
echo "$nome";
To display the value "name" the page seems not to load , the whole screen turns white..

How can I display the "name" value correctly ?

Thank you to all who can help me.

1 answer

3


$nome = $json_str["response"]["players"]["76561198012598620"]["name"];
echo "$nome";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.