So right now I'm pulling data from a json API (battle.net) with this request
http://ift.tt/1M97Mhk
API key hidden intentionally, this returns the following
{
"realms": [{
"type": "pve",
"population": "medium",
"queue": false,
"wintergrasp": {
"area": 1,
"controlling-faction": 1,
"status": 0,
"next": 1433468324674
},
"tol-barad": {
"area": 21,
"controlling-faction": 1,
"status": 2,
"next": 1433465638814
},
"status": true,
"name": "Runetotem",
"slug": "runetotem",
"battlegroup": "Vengeance",
"locale": "en_US",
"timezone": "America/Los_Angeles",
"connected_realms": ["uther", "runetotem"]
}]
}
Which I am putting into an array using php and then attempting to call upon values from said array in an if statement, however the if statement is always firing true for my check. I don't understand why at all, if someone could please help that'd be great. Code below.
<?php
$json_url = "http://ift.tt/1H6nuds";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
?>
<tr class="latestthreads_portal">
<td width="230px" class="trow3">
<strong>Realm Status</strong>
<span class="smalltext"><br />
<?php if ($data['realms'][0]['status'] == 2)
{
echo "up";
}
else{
echo "Down?";
}
?>
<br />
<br /> <div class="border"></div>
</span>
</td>
</tr>
Please excuse crappy formatting, in a rush.
Aucun commentaire:
Enregistrer un commentaire