I get json data from a website. I then save this data to the .txt file.
{
m: [
{
d: '08.01.2015',
m: [
[
2875678,
'id1',
77,
'id2',
'100',
0,
'21:20',
'',
'',
'3',
'',
'1',
'-',
'1.09',
'2.06',
'2.05',
'1.40',
'92334',
{
tId: 92334
},
'\u0130S1',
'14',
'20'
]
]
}
]
}
The contents of the .txt file are as above.I want to make this .txt file a array.But when using json_decode the result is blank.
$file= fopen("test.txt", "r");
if( $file == false ) {
echo ( "error!" );
exit();
}else {
while (!feof($file)) {
$read = fgets($file);
$decode = json_decode($read, true);
print_r($decode);
}
}
fclose($file);
How can I convert it into an array? EDİT: data saved with this code.
$data = cURL($url);
$urlHandle = _fwrite($data);
$datam = $data;
$data = json_decode($datam,true);
function _fwrite($data1)
{
$file = fopen('test.txt','w');
fwrite($file,$data1);
fclose($file);
}
jsonlint.comjson_last_error_msg();andecho json_last_error();