title: json_decode: object to associative array
body: <p>How can I convert this horrible piece of code to an associative array? :D</p>
  
  <pre><code>&lt;?php
  $json = file_get_contents('http://pastebin.com/NLHGMapT');
  $track_data = json_decode($json);
  ?&gt;
  &lt;ul&gt;
  &lt;?php
      foreach ($track_data as $data)
  
              $text0 = $data-&gt;track[0]-&gt;artist-&gt;{'#text'};
              $text1 = $data-&gt;track[1]-&gt;artist-&gt;{'#text'};
              $text2 = $data-&gt;track[2]-&gt;artist-&gt;{'#text'};
              $text3 = $data-&gt;track[3]-&gt;artist-&gt;{'#text'};
              $artist0 = $data-&gt;track[0]-&gt;name;
              $artist1 = $data-&gt;track[1]-&gt;name;
              $artist2 = $data-&gt;track[2]-&gt;name;
              $artist3 = $data-&gt;track[3]-&gt;name;
              $url0 = $data-&gt;track[0]-&gt;url;
              $url1 = $data-&gt;track[1]-&gt;url;
              $url2 = $data-&gt;track[2]-&gt;url;
              $url3 = $data-&gt;track[3]-&gt;url;
          echo '&lt;li&gt;&lt;a href="'; echo $url0; echo '"&gt;&lt;span&gt;'; echo $text0; echo '&lt;/span&gt; - &lt;span&gt;'; echo $artist0; echo '&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;';
          echo '&lt;li&gt;&lt;a href="'; echo $url1; echo '"&gt;&lt;span&gt;'; echo $text1; echo '&lt;/span&gt; - &lt;span&gt;'; echo $artist1; echo '&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;';
          echo '&lt;li&gt;&lt;a href="'; echo $url2; echo '"&gt;&lt;span&gt;'; echo $text2; echo '&lt;/span&gt; - &lt;span&gt;'; echo $artist2; echo '&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;';
          echo '&lt;li&gt;&lt;a href="'; echo $url3; echo '"&gt;&lt;span&gt;'; echo $text3; echo '&lt;/span&gt; - &lt;span&gt;'; echo $artist3; echo '&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;';
  ?&gt;
  &lt;/ul&gt;
  </code></pre>