Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am retrieving a huge string from the WoW Armory API using:

$allAchievements = file_get_contents('http://us.battle.net/api/wow/data/character/achievements');

That returns this:

http://us.battle.net/api/wow/data/character/achievements

I am trying to convert this into a manageable format such as an array that would look similar to:

[achievements]=> array
             (
            [0]=> Array 
               (
                [id]=>6, 
                [title]=>Level 10, 
                [points]=>10, 
                [description]=>Reach Level 10.,
                [rewardItems]=>[],
                [icon]=>achievement_level_10,
                [criteria]=>[],
                [accountWide]=>false,
                [factionId]=>2,
                )
            [1]=> Array 
               (
                [id]=>7, 
                [title]=>Level 20, 
                [points]=>10, 
                [description]=>Reach Level 20.,
                [rewardItems]=>[],
                [icon]=>achievement_level_20,
                [criteria]=>[],
                [accountWide]=>false,
                [factionId]=>2,
                ) 
               ... 
              )

I have tried numerous combinations of explode() and parse_str() but i haven't been able to create any kind of array that would prove to be any use to me.

Is there a way to use file_get_contents(); so that a array would be returned in stead of a string?

If not, where should i start to expand this huge string into a manageable array?

Thank You for any help!

share|improve this question

1 Answer

up vote 1 down vote accepted

use this

$allAchievements = file_get_contents('http://us.battle.net/api/wow/data/character/achievements');
$newArray = json_decode($allAchievements, true);
share|improve this answer
 
Works perfect. Thank you. –  user2375300 May 12 at 17:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.