Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. $myFile = "example.com/json/";
  2. $jsonfile = "/home/example/public_html/example.json";
  3.  
  4. file_put_contents($jsonfile, ""); //empties the file
  5.  
  6.  
  7. try
  8. {
  9.  
  10. $cache_buster = date("YmdHi");
  11. $footerdata = 'example.com/example.json?v='.$cache_buster;
  12.  
  13. //Get data from existing json file
  14. $jsondata = file_get_contents($myFile);
  15.  
  16. //write json data into data.json file
  17. if(file_put_contents($jsonfile, $jsondata)) {
  18. echo 'Data successfully saved';
  19. }
  20. else
  21. echo "error";
  22.  
  23. }
  24. catch (Exception $e) {
  25. echo 'Caught exception: ', $e->getMessage(), "n";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement