What is the correct way to use an if statement with a json response?
This is my current code.
<?php
$link =file_get_contents('xxxxxxxxxx');
$res=json_decode($link, true);
echo "Currently: ";
if ($res['response'][0]['personastate'] == '1') {
echo "Online";
else if
echo "Offline";
}
?>
Printing the response via
print $res['response'][0]['personastate'];
works just fine, resulting in a 1 or a 0 being printed.
Where did I go wrong? I can't find any information on anything similar to my problem.
Aucun commentaire:
Enregistrer un commentaire