Variables in a JSON - PHP

1

Is there any way to vary the value of a JSON? Let's take an example:

I have the following JSON

{
    "ISteamClient": 0,
    "ISteamFriends": 0,
    "ISteamUser": 0,
    "IEconItems_440": 0,
    "IEconItems_730": 0,
    "ISteamGameCoordinator_440": 0,
    "ISteamGameCoordinator_570": 0
}

After using

$clientesteam = $json_str["ISteamCliente"];
echo "O Cliente Steam esta $clientesteam";

The serial result: The Steam client is 0

Is there a way to turn this "0" into "Online"?

    
asked by anonymous 10.02.2015 / 00:00

1 answer

5

There are several ways, I do not know if I understand. For you to get focused answers on what you want you have to master the question. Bad questions generate off-target responses. But I will try already saying that if I understood the objective, your problem has nothing with the JSON or APIs, it is very basic algorithm:

$clientesteam = $json_str["ISteamCliente"];
echo "O Cliente Steam esta " . ($clientesteam == 0 ? "Online" : "Offline");

See running on ideone .

Ternary Operator Documentation .

    
10.02.2015 / 00:12