<?php
if(file_exists("upload.json"))
{
// For GETTING Values as an Associative Array...
$temp_array = array();
$temp_array = json_decode(file_get_contents('upload.json'),true);
$upload_info = array('media_name'=>'b',
'media_category'=>'v','media_info'=>'c','media_location'=>'x','media_artist'=>'z');
array_push($temp_array, $upload_info);
file_put_contents('upload.json', json_encode($upload_info));
}
else
{
$upload_info =array('media_name'=>'b',
'media_category'=>'v','media_info'=>'c','media_location'=>'x','media_artist'=>'z');
$json = json_encode($upload_info);
$file = "upload.json";
file_put_contents($file, json_encode($json));
}
?>
JSON ファイルを一緒に追加できません: 解決策はありますか? 前もって感謝します 。
次の順序で JSON ファイルが必要です。
{
"upload":
{
"image":[
{
"media_name": "b",
"media_category": "v",
"media_info": "c",
"media_location": "x",
"media_artist": "z"
},
{
"media_name": "b",
"media_category": "v",
"media_info": "c",
"media_location": "x",
"media_artist": "z"
}
]
}
}
私は何をすべきか ??