Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $myFile = "example.com/json/";
- $jsonfile = "/home/example/public_html/example.json";
- file_put_contents($jsonfile, ""); //empties the file
- try
- {
- $cache_buster = date("YmdHi");
- $footerdata = 'example.com/example.json?v='.$cache_buster;
- //Get data from existing json file
- $jsondata = file_get_contents($myFile);
- //write json data into data.json file
- if(file_put_contents($jsonfile, $jsondata)) {
- echo 'Data successfully saved';
- }
- else
- echo "error";
- }
- catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement