1
Is there any way to vary the value of a JSON? Let’s look at 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: Steam client is 0
Is there any way to turn this "0" into "Online"?
In Parts Worked , only resulted in "Online", you can see the result in http://leonardo.noip.me , now to display "Offline" if the value is "1" the code would echo "The Steam Client this " . $clientesteam == 0 ? "Online" : 1 ?" Offline";
– Leonardo Roberto
I updated it in ideone showing that with 1 it works normal. You don’t have to move anything in the syntax to work. In fact I find this manipulation a naive way, I have my doubts whether it will work in all cases but I can only answer upon what you posted.
– Maniero
My Code looks like this http://ideone.com/qA4LeS I only want when the value is "0" to be displayed online and when the value is "1" to be displayed offline, because JSON comes from an external website that says whether the Steam Steam ON Client or OFF
– Leonardo Roberto
And what’s the problem you’re seeing in it?
– Maniero
the phrase "The Steam Client this" does not appear , it only appears "Online", but I think I decided to do a gambit with html. <p> Steam Client is <?php echo "" . $clientesteam == 0 ? "Online" : "Offline"; ? > </p>
– Leonardo Roberto
Sniffing around, making it work by coincidence is never a good idea. I edited, what I posted here in response is different from what I showed performing, I had forgotten the parentheses. But the demonstration of ideone was already right.
– Maniero
It worked perfectly, Thanks.... I ask every stupid question here at Stackoverflow , I’m trying to learn PHP myself.
– Leonardo Roberto
Exactly this is what you need to do. Go learn, don’t try to do without knowing. Fatally you will make many "invisible" mistakes and will not realize until you cause a bigger problem.
– Maniero
@Leonardoroberto I don’t think your question is stupid. It may be basic, but everyone who programs in PHP or any.
– Franchesco