title: How to converting JSON text to PHP associative array
body: <p>I have the following JSON Object stored in a text file(data.txt):</p>
  
  <pre><code>{"player":"black","time":"0","from":"2c","to":"3d"}
  </code></pre>
  
  <p>Which i read using php:</p>
  
  <pre><code>&lt;?php
    $data = file_get_contents('data.txt');
  ?&gt;
  </code></pre>
  
  <p><strong>Question:</strong> Is there an easy way to convert <code>$data</code> to a PHP associative array. I have tried using <code>json_decode($data);</code> but that did not work, any suggestions?</p>