Im currently playing around with some php and JSON, i know abit of PHP pretty much nothing of JSON but ive managed to get about halfway where i need to be currently i have this section of code.
<?php
$json = file_get_contents('http://eu.battle.net/api/wow/character/Ragnaros/Smoosher?fields=progression');
$data = json_decode($json, true);
foreach ($data['progression']['raids'] as $raid) {
echo "Raid: ", $raid['name'];
echo " Normal: ", $raid['normal'];
echo " Heroic: ", $raid['heroic'];
echo " id: ", $raid['id'];
echo " Boss's: ", $raid['bosses']['name'];
?>
<p>
<?php
};
foreach ($data['progression']['raids']['bosses'] as $boss) {
echo " Boss Name: ", $boss['name'];
}
print_r($boss);
#echo $data->name;
?>
Now the first foreach works fine, no issues what that it pulls the data out into the page fine, however i noticed that seemed to be another (Array?) within the one i was out putting so first i tried
echo " Boss's: ", $raid['bosses']['name'];
Which outputs nothing but the word boss's, and nothing from within the array, so i thought maybe i need another foreach statement and start pulling that through. However this part
foreach ($data['progression']['raids']['bosses'] as $boss) {
echo " Boss Name: ", $boss['name'];
}
Gives an error
Warning: Invalid argument supplied for foreach() in xxxxxx/xx/xxxxx/wow/test.php on line 22
And i cant see what im doing wrong :( any help would be great, the json im pulling from is
http://eu.battle.net/api/wow/character/Ragnaros/Smoosher?fields=progression