index.jsonнеприятности обновить или отредактировать файл JSON с помощью PHP
myjsoncallback([{"ProductID":1,"ProductName":"Chai","UnitPrice":18,"UnitsInStock":39,"Discontinued":false}])
Php Код:
$string = file_get_contents("../index.json");
$string = utf8_encode($string);
$json_data = json_decode($string, true);
echo $json_data;
$i=count($json_data);
$json_data[$i] = array('ProductID'=>$fileName,'ProductName'=>$name,'ptext'=>$message,'Discontinued'=>false);
$fp = fopen('../index.json', 'a');
fwrite($fp, json_encode($json_data));
fclose($fp);
Я хочу, чтобы записать данные в файл с jsone jsonpcallback.
Почему вы используете utf8_encode() – Svetoslav