我加載JSON文件來自:PHP - 加載JSON,編輯和保存
{ "timestampRead": [11, 22, 33], "timestampCurrent": [66, 77, 88] }
到PHP:
$local_json = json_decode(file_get_contents('/Temp/chat-users.json'));
,我不知道我可以:
- 更新timestampRead所有值(
$local_json->timestampRead[] = '99'?
) - 更新一個在timestampCurrent(值
$local_json->timestampCurrent[2] = '33'
) - 保存更新的JSON到文件(
$local_json array to json
)
[如何更新/編輯以.json的可能重複文件使用PHP](http://stackoverflow.com/questions/17806224/how-to-update-edit-json-file-using-php) – vzamanillo
你嘗試過什麼嗎?它有用嗎?如果不是,它以什麼方式不起作用? –
線索 - 1和2工作。 3 - 你認爲json_decode的反面可能是什麼?你認爲file_get_contents的反義詞可能是什麼?最後的線索 - php.net –