I have the following JSON object stored in a text file (data.txt):
{"player":"black","time":"0","from":"2c","to":"3d"}
What I read with php:
<?php
$data = file_get_contents('data.txt');
?>
Question: Is there an easy way to convert $datato an associative PHP array. I tried using json_decode($data);, but that didn't work, any suggestions?
source
share