从url下载并存储JSON文件.PHP


Download and store JSON file from url. PHP

在我的项目中,我必须从URL获取和存储JSON数据。我已经设法获得JSON数据使用file_get_contents。现在我希望以JSON格式将检索到的数据存储到文件夹中。这可能吗?如果有,我该怎么做?

file_put_contents()就可以了。

file_put_contents('someFileName.json', $yourStringOfJson);
http://www.php.net/manual/en/function.file-put-contents.php